-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Add indicator of current silo in the prompt when running denote commands #432
Comments
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` or `Art` is the last directory name of the path, as
specified in the `denote-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
|
Thanks to IceAsteroid for suggesting this in issue 432: <#432>.
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 I've also set up the It seems that the switched silo is remembered as the default selected candidate when I once again invoke one of the commands like The documentation says:
|
It must visit a file in a silo directory, or with 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 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 But 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:
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
That's basically it, it's complicated then it seems. |
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 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. |
That's the problem here. I wish to switch to a silo by any of the above provided command. That the selected silo is picked up each time when I create notes, by any of the denote commands. Not being interfered by any of the opened notes that belong to other silos when my Plus when the current buffer is not a note of any silo, creating a note with the No matter the current buffer is at a note of any silo, at any random files, or buffers, after the a "switch command" has set it to a silo, I wish all commands not being interfered by any of the factors mentioned, just create notes in the selected silo. Which just treats silo paths like in global variable And also define the switch command, say Also, delete the created Except that there's still a need that tells which directory the denote is working on as an indicator. Maybe you should check the comments here in Github, I edited a lot of my comments, I'm not sure that email could show the latest edit. |
GNU Emacs 29.4 (build 2, x86_64-unknown-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) of 2024-06-25 |
From: IceAsteroid ***@***.***>
Date: Fri, 20 Sep 2024 09:22:58 -0700
> 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.
That's the problem here. I wish to switch to a silo by any of the
above provided command. That the selected silo is picked up each time
when I create notes, by any of the denote commands.
Not interfered by any of the opened notes that belong to other silos
when my `current-buffer` is at any of them.
If you always want to be asked for the silo, then you can use the
command 'denote-silo-extras-create-note'. There is a variant of this
which also asks you which command you want to run in the given silo:
'denote-silo-extras-select-silo-then-command'.
Plus when the current buffer is not a note of any silo, creating a
note with the `denote-create-note` command just creates a note that
its path is the `denote-directory` global variable's value.
Indeed. This is the desired behaviour, because we assume that the user
does not explicitly want to work in the silo. Users who need to do so
either switch to the silo and then call 'denote' (or related command),
or they use the denote-silo-extras I mentioned above.
Which in reverse, I want it to create a note in the selected silo.
----
No matter the current buffer is at a note of any silo, at any random
files, or buffers, after the "switch commands" has set it to a silo, I
wish all commands not being interfered by any of the factors
mentioned, just create notes in the selected silo.
----
I see. Then please check what we have in denote-silo-extras.el. If there
is something missing from there, we can add it.
Which just treats silo paths like in global variable
`denote-directory`, this is doable even by myself. Just define a list
variable, say `my-denote-separated-directories`, containing paths of
said `silo A`, `silo B`, and `silo C`.
This is different and we already cover it in the manual under the
section with the title "Create a new note in any directory". Here is the
code for your convenience:
(defun my-denote-create-note-in-any-directory ()
"Create new Denote note in any directory.
Prompt for the directory using minibuffer completion."
(declare (interactive-only t))
(interactive)
(let ((denote-directory (read-directory-name "New note in: " nil nil :must-match)))
(call-interactively 'denote)))
And also define the switch command, say
`my-denote-switch-to-a-directory`, to change the global variable
`denote-directory`'s value to the selected path that is one of the
values of `my-denote-separated-directories'.
If we are to be switching the global value of the denote-directory, then
we do not need the silo facility at all. This can be done, of course,
though it was not part of the original idea of this exchange.
Using the 'my-denote-silo-extras-dired-to-silo' as an example, here is
how to go about it:
(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)))
(setq denote-directory silo)
(message "Switch `denote-directory' to `%s'" silo)
(denote-silo-extras-with-silo silo
(dired silo)))
Also, delete created `dir-locals.el` files in all those silos with
this usage. At this rate, they're not used as silos in denote, but
just like a standalone `denote directory`, switching to any of them
shadows any of others like non-existent to `denote`'s commands.
Invoking denote commands only work on the selected directory's notes.
Indeed, if you plan to change the denote-directory each time, you do not
need to use silos.
Except that there's still a need that tells which directory the denote
is working on as an indicator.
If you are always going to select the directory you will operate on,
then the indicator will not make much of a difference.
Still this is a feature I need to consider further. I think it can be
useful, though I have to decide how best it can be done.
…--
Protesilaos Stavrou
https://protesilaos.com
|
I decided to use the method of "changing the And there also needs wrapper commands for the directory switch and then doing actions just like All the described features above in this comment are simple configurations of the current functionality of denote, they also don't interfere or change the way silos behave. So they can work along with silos. I'll try to implement the above features in my own init file.
However, I still think it's necessary, otherwise, in the workflow, when creating notes, I still need to check the value of [Fix typo] Directory is still sometimes getting switched when use. If the user doesn't need to switch, with the method I described above, nor using silos, he doesn't have to concern about this. Maybe, if the path is one of the silo paths, display indicator like
That's good, Protesilaos. It's on your decision. I'll then just do something convenient in my own init config first. |
From: IceAsteroid ***@***.***>
Date: Sat, 21 Sep 2024 02:30:46 -0700
> Maybe you should check the comments here in Github, I edited a lot of my comments, I'm not sure that email could show the latest edit.
I see, but then it is hard for me to keep track of everything. You will
notice that this project is very active---and I have many more!
Sometimes I am on the website (e.g. to merge a pull request), but it is
not as convenient as using email inside of Emacs to deal with
everything. If I am missing something essential, just let me know.
----
I decided to use the method of "changing the `denote-directory` global
variable for the 'directory switch'" instead of using silos. Like I
said, after the switch, denote should create notes in that selected
directory, regardless of any other factors. This perfectly fits my
needs.
[... 13 lines elided]
I'll try to implement the above features in my own init file.
Very well!
> If you are always going to select the directory you will operate then
> the indicator will not make much of a difference.
However, I still think it's necessary, otherwise, in the workflow,
when creating notes, I still need to check the value of
`denote-directory`, in order to make sure which directory will be used
to create the note in, since my memorization is not that good these
days :(
My comment here is based on the assumption that you are always prompted
for a directory. In that scenario, the indicator does not give you any
more information than what you already know from the directory-selection.
Directory is still sometimes getting switched when use. If the user
doesn't need to switch, with the method I described above, or using
silos, he doesn't have to concern about this.
Since you will define the functions for your use-case, I think it is
fine to optimise for your specific needs (like what you want to do with
setting the global 'denote-directory').
Maybe, if the path is one of the silo paths, display indicator like
`Silo:_lastDirName_`, if it's not a silo path, display
`Dir:_lastDirName_`.
----
> Still this is a feature I need to consider further. I think it can be
> useful, though I have to decide how best it can be done.
That's good, Protesilaos. It's on your decision. I'll then just do
something convenient in my own init config first.
The indicator is worth exploring. I do not know if I will implement
though. It will depend on how complex it is. I will at least cover it in
the manual.
…--
Protesilaos Stavrou
https://protesilaos.com
|
That's understandable. |
Here's the code that I implemented for denote to work with "switching directories". Not yet to implement the indicator.
But I got a problem, it must use the first part of the following code instead of the second, in order to make it prompt the minibuffer, but I don't wanna make the advicing function to be a command by being interactive. When I use the second part, it works for all other commands. Except the "denote" command, and I've tried lots of ways, for example, using a lambda inside the advicing function, making the lambda interactive, and such, they all don't work except making the advicing function itself to be interactive. Is it something wrong with the The first part:
The second part:
|
After all my required features are implemented and sharped, I'll post the code again here or in a discussion page with a more accurate title, to just share it, it may be helpful for someone. |
Almost done here. The code isn't that sharped, and I feel the urge to post, I got another different method(probably better). Note, when the current buffer is on a note belonging to a denote path, where it's opened via The However, the implemented indicator just displays it correctly in the prompt when a denote command that's used to create a note, is invoked. When this case happens, just use the implemented Here's another method and it's more hassle-free to implement. Which is to: 1.1. Prompt the user for the confirmation of the directory before denote commands that create notes actually are executed. 2.1. After the prompt, execute the actual desired command. The reason is because it needs not only to redefine the And it's also less-consistent, for example, the command The It's also gonna alter the code of This is the old code that consists two parts: The first part's for switching denote directories
The second part's for the current denote directory indicator in prompt
Except the code implemented in the init file, the
This is the demo code & video of the new idea that prompts a minibuffer with a give limited of time before the actual denote command runs. Somehow a pain at least for me to figure out how to run another expression while an interative expression is still in the middle of the run. But I achieved it, it may look ugly and be unefficient, if you know better, please tell me.
denote-indicator-new-method.mp4 |
I'm sorry for the non-sense. The code in my last previous comment that was to implement the prompt the directory switch within a given limited time when idle, lasting if anything is typed before denote commands, has been done in my test, but it's uglier than necessary. And I found out it's harder than the old code. Since the implemented It's saner just to use the old one, with some minor changes. Here's the code, not that good, but enough for personal use. It has two parts, the "switch directory one" and the "indicator" one.
And the re-definition of the
I'm already very happy with what I've done for my needs. And I'm sorry, Protesilaos. For the confusion I made so far. I hope it didn't bother you much. |
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.
The text was updated successfully, but these errors were encountered: