Open IceAsteroid opened 6 days ago
Thank you for taking the time to write this!
From: IceAsteroid @.***> Date: Thu, 12 Sep 2024 07:27:16 -0700
[... 7 lines elided]
Here's some suggestions:
- Add a command in
denote-silo-extras.el
to only switch to a silo and do nothing, compared to other commands that must run actions after execution.
Since we do not have such commands in general, I think we can cover this through documentation. Also because the users may just as well use Emacs bookmarks to go to their frequently used directories.
Here is the code to do what you want:
(defun my-denote-silo-extras-dired-to-silo (silo)
"Switch to SILO directory using `dired'.
SILO is a file path from `denote-silo-extras-directories'.
When called from Lisp, SILO is a file system path to a directory that
conforms with `denote-silo-extras-path-is-silo-p'."
(interactive (list (denote-silo-extras-directory-prompt)))
(denote-silo-extras-with-silo silo
(dired silo)))
(defun my-denote-silo-extras-cd-to-silo (silo)
"Switch to SILO directory using `cd'.
SILO is a file path from `denote-silo-extras-directories'.
When called from Lisp, SILO is a file system path to a directory that
conforms with `denote-silo-extras-path-is-silo-p'."
(interactive (list (denote-silo-extras-directory-prompt)))
(denote-silo-extras-with-silo silo
(cd silo)))
Note that you need to update 'denote' as I just added the 'denote-silo-extras-with-silo'.
- Add an indicator string, say if I have two silos "IT" and "Art", and current in the "IT" silo, when I execute the
denote
command and the minibuffer's prompt shall be like:1/23 In IT New file TITLE:
- Either
IT
orArt
is the last directory name of the path, as specified in thedenote-silo-extras-directories
variable. For example:~/OrgWiki/IT
and~/OrgWiki/Art
.
I think this is a good idea. Given that it is more likely to be used in tandem with the denote-silo-extras.el, we should add this functionality there. A user option can be provided as well, so that interested parties can opt-in while the rest maintain what they have.
What do you think?
-- Protesilaos Stavrou https://protesilaos.com
Note that you need to update 'denote' as I just added the 'denote-silo-extras-with-silo'.
Sorry for the delay, I'm trying to figure out how to upgrade the package to a lastest commit from source, since it seems not being shipped with the latest version. I gotta try the code first.
No worries! Here is the code that you can use without upgrading:
(defun denote-silo-extras-path-is-silo-p (path)
"Return non-nil if PATH is among `denote-silo-extras-directories'."
(member path denote-silo-extras-directories))
(defun my-denote-silo-extras-dired-to-silo (silo)
"Switch to SILO directory using `dired'.
SILO is a file path from `denote-silo-extras-directories'.
When called from Lisp, SILO is a file system path to a directory that
conforms with `denote-silo-extras-path-is-silo-p'."
(interactive (list (denote-silo-extras-directory-prompt)))
(if (denote-silo-extras-path-is-silo-p silo)
(dired silo)
(user-error "`%s' is not among the `denote-silo-extras-directories'" silo)))
(defun my-denote-silo-extras-cd-to-silo (silo)
"Switch to SILO directory using `cd'.
SILO is a file path from `denote-silo-extras-directories'.
When called from Lisp, SILO is a file system path to a directory that
conforms with `denote-silo-extras-path-is-silo-p'."
(interactive (list (denote-silo-extras-directory-prompt)))
(if (denote-silo-extras-path-is-silo-p silo)
(cd silo)
(user-error "`%s' is not among the `denote-silo-extras-directories'" silo)))
EDIT: added a missing function.
I might understand it wrong.(I got busy, sorry to be late)
After I switched to a silo with the provided commands above, invoking the command denote-create-note
won't create the note in the selected silo, but instead it's created in the directory set in the denote-directory
variable.
I've also set up the .dir-locals.el
file in each silo's directory and made it executable.
It seems that the switched silo is remembered as the default selected candidate when I once again invoke one of the commands like denote-silo-extras-create-note
, in the minibuffer with vertico
enabled. Is this what's supposed to work?
The documentation says:
When inside the directory that contains this .dir-locals.el file, all Denote commands/functions for note creation, linking, the inference of available keywords, et cetera will use the silo as their point of reference (How to switch a silo). They will not read the global value of denote-directory. The global value of denote-directory is read everywhere else except the silos.
It must visit a file in a silo directory, or with my-denote-silo-extras-dired-to-silo
to open a dired buffer in the silo's directory and it must also be opened in the "current buffer", in order to make the dir-locals.el
file set the directory-variables. And the my-denote-silo-extras-cd-to-silo
command would not work.
That being said, it's not about the switch on which silo to use, but it depends on the visiting of files in a silo. Even though it was switched to another silo with the commands provided above, say silo A, but the visiting file in the "current buffer" is in silo B, the note creation will still pick silo B instead, because of dir-locals.el
in each silo, that sets the denote-directory
variable to the path of silo.
Which makes the switch on silo senseless, the user will still mess up that which silo is in use, or he has to visit a file in a desired silo, or to open the silo directory with dired every time when he creates a note.
In short, the commands denote-silo-extras-create-note
, denote-silo-extras-open-or-create
, and denote-silo-extras-select-silo-then-command
work just fine.
But my-denote-silo-extras-cd-to-silo
doesn't work, and my-denote-silo-extras-dired-to-silo
does work unexpectedly with the description of this feature request.
I think this working mechanism on silos by itself is a bit chaotic, I've been trying lots of tests just to figure out, I didn't mean to be confusing, sorry.
In the current setup, It's leaving a few options for me:
Switch to a silo with my-denote-silo-extras-dired-to-silo
. And do not manually visit files in any silo via other commands like find-file
, to prevent confusion on which silo is in use, by first switching to a silo before visiting a desired note.
Use existing commands denote-silo-extras-create-note
, denote-silo-extras-open-or-create
, and denote-silo-extras-select-silo-then-command
. And consult-notes
must be used only after any of the listed commands, in order to open in the right silo.
Plus each time when done visiting notes in a silo and before switching to another silo, I have to close the buffers of the visited notes all to prevent they mess up denote-directory
again when switching buffers!
Do not use dir-locals.el
to set directory variables, but instead have some way to set the denote-directory
after the switch to a silo.
Don't use silos at all..
That's basically it, it's complicated then it seems.
Plus each time when done visiting notes in a silo and before switching to another silo, I have to close the buffers of the visited notes all to prevent they mess up
denote-directory
again when switching buffers!
I do not know exactly how your workflow is, but you do not need to close any buffers for the active silo to be picked up each time. The directory-local variables apply to the files in those directories as well, so when you switch to another buffer that belongs to a different silo Emacs will read a new directory-local variable.
The code I shared with you earlier does what it intends, namely to prompt for a silo and then use cd
or dired
there. The cd
, for example, is useful if your next command is something that searches the current directory. So these are technically not wrong, but I understand they are not what you expect.
Let's then take a step back. Can you describe me what your preferred workflow is? I will then see what I can do.
Also, please tell me what version of Emacs you are on.
Hi, greetings, guys!
I found it's inefficient to identify the current silo after switching to one of them.
In my use case, a silo will contain a large amount of org files, each silo is for a specific field of research.
After I switched to a silo, it's rare to switch to another silo during the day or some few days, but sometimes after the switch, I must know which silo I'm current in, otherwise, I'd mess up and a newly created note by me will reside in an undesired silo instead.
Here's some suggestions:
(I'm using the vertico package, something might be displayed a bit different here)
denote-silo-extras-directories
variable. For example:~/OrgWiki/IT
and~/OrgWiki/Art
.It's more nice to also add the silo indicator for consult-notes, but that's another discussion, I'll post it on the consult-notes' repo issue page.