Skip to content
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

Org links do not work between notes created in parent directories. #121

Closed
MirkoHernandez opened this issue Dec 31, 2022 · 6 comments
Closed

Comments

@MirkoHernandez
Copy link

I believe this is related to issue #114.

Creating notes in directories and then opening org links between them leads to an error Wrong type argument: stringp, nil
(The links do not work towards a note in a parent directory).

My current workaround is to point denote-directory to a root directory in a function and use that instead of org-open-at-point.
(also to open the link in the same window).

(defun my/org-open-at-point-same-window ()
 (interactive) 
 (let ((denote-directory my-denote-root-directory )
         (org-link-frame-setup (cl-acons 'file 'find-file org-link-frame-setup)))
   (org-open-at-point)))

My previous solution involved applying the same to denote-link-ol-follow.

On a related note, the 1.2.0 version includes a new version of denote-link using a different denote-file-prompt. I really like the new version but would it be possible to have the old behavior as a new function ?. It was very convenient for linking notes in different directories.

Also thanks a lot @protesilaos for the new signature features. I will be testing and using those a lot this week.

@protesilaos
Copy link
Owner

Creating notes in directories and then opening org links between them leads to an error

Can you please give me a sample directory structure to try this? You mean a link from a subdirectory to the parent directory?

I really like the new version but would it be possible to have the old behavior as a new function ?. It was very convenient for linking notes in different directories.

This will require a change to denote-file-prompt because it is used internally by denote-link. It affects other commands as well.

I guess this depends on the directory structure, though I find the new prompt just as easy to use. For example, I have a misc subdirectory and if I type that in the prompt I immediately get the list filtered accordingly. With the help of the orderless package, I can type ^misc and then filter further like ^misc _keyword -title.

@MirkoHernandez
Copy link
Author

Yes, for instance:

  • denote-root/reference/tmux/note-with-link-to-note-b.
  • denote-root/reference/bash/note-b

Or something like this with similar nesting.

I guess this depends on the directory structure, though I find the new prompt just as easy to use.

I also think that the new behavior is better. I'm not suggesting modifying denote-file-prompt , maybe making the prompt an optional parameter and using denote-file-prompt as the default.

I don't think that using directories in the mentioned way is an unusual workflow. The link problem is the main issue and the suggested command is just for convenience,

@protesilaos
Copy link
Owner

Or something like this with similar nesting.

I cannot reproduce this. Maybe you are experiencing this problem in a "silo"?

I don't think that using directories in the mentioned way is an unusual workflow. The link problem is the main issue and the suggested command is just for convenience,

It will be tricky to add it directly to denote.el as it will set a precedent for multiple styles of prompt. Though we can document it in the manual. Here is the idea:

(defun denote-file-prompt-original (&optional initial-text)
  "Prompt for file with identifier in variable `denote-directory'.
With optional INITIAL-TEXT, use it to prepopulate the minibuffer."
  (read-file-name "Select note: " (denote-directory) nil nil initial-text
                  (lambda (f)
                    (or (denote-file-has-identifier-p f)
                        (file-directory-p f)))))

(defun my-denote-link ()
  "Call `denote-link' but use the generic file prompt.
See `denote-file-prompt-original'."
  (interactive)
  (cl-letf (((symbol-function 'denote-file-prompt) #'denote-file-prompt-original))
    (call-interactively #'denote-link)))

@MirkoHernandez
Copy link
Author

I cannot reproduce this. Maybe you are experiencing this problem in a "silo"?

You are probably right, I used to use the old (a few months ago) method of adding a .dirs-locals.el in each directory. Recent versions of denote are much better at handling the creation of notes in directories. I will try to debug this in a clean setup.

Thanks for the code suggestion this what I was trying to do (unsuccessfully using let instead of cl-letf).

@protesilaos
Copy link
Owner

I will try to debug this in a clean setup.

Okay. I will keep this issue open until we have a clear picture.

Thanks for the code suggestion this what I was trying to do
(unsuccessfully using let instead of cl-letf).

You are welcome! I will add this as an example in the manual.

protesilaos added a commit that referenced this issue Jan 5, 2023
This is my solution to a request made by Mirko Hernandez on the
possible use of the old Denote file prompt.  It is better not to
introduce a user option for this case, nor to keep multiple variants
of the 'denote-file-prompt' in denote.el, as we want to avoid
confusing the users.

Mirko's feedback was provided in issue 121 on the GitHub mirror:
<#121>.
@MirkoHernandez
Copy link
Author

I can confirm that the links work as expected in a normal configuration. I had set up a .dir-locals.el in the root directory pointing to default-directory, this causes some links to break because of the "silo" situation. I have been using this for months so I thought It was the default denote behavior.

The advantage of the mentioned setup is that a call to denote (or denote-link) inside any directory (using dired or in any buffer) creates the note in the expected place, otherwise the notes are created in the root dir (I believe this is the intended behavior but not ideal for a workflow in which, almost exclusively, notes are created inside directories) .

With the suggested function I have everything I need to link between directories without any problem, thanks @protesilaos. For documentation purposes this is how everything is set:

  • .dir-locals.el (set to default-directory) only in root directory.
  • wrapper to org-open-at-point (just sets denote-directory to the root directory).
  • denote-link function to link any file in any directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants