Skip to content

Commit

Permalink
Tweak denote-link-add-links code
Browse files Browse the repository at this point in the history
  • Loading branch information
protesilaos committed Oct 1, 2022
1 parent 2c2eb5d commit 2c71843
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions denote.el
Original file line number Diff line number Diff line change
Expand Up @@ -2509,11 +2509,11 @@ inserts links with just the identifier."
(read-regexp "Insert links matching REGEX: " nil 'denote-link--add-links-history)
current-prefix-arg))
(let ((current-file (buffer-file-name)))
(if-let ((files (delete current-file (denote-directory-files-matching-regexp regexp))))
(let ((beg (point)))
(if-let ((files (delete current-file (denote-directory-files-matching-regexp regexp)))
(beg (point)))
(progn
(insert (denote-link--prepare-links files current-file id-only))
(unless (derived-mode-p 'org-mode)
(denote-link-buttonize-buffer beg (point))))
(denote-link-buttonize-buffer beg (point)))
(user-error "No links matching `%s'" regexp))))

(defalias 'denote-link-insert-links-matching-regexp (symbol-function 'denote-link-add-links))
Expand Down

4 comments on commit 2c71843

@protesilaos
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EFLS I just realised why you did it that way in denote-link-add-missing-links with the if-let and then let. I this tweaking them this way is good for consistency.

I think both commands should move away from the user-error here. It could be just a message. Any thoughts?

@EFLS
Copy link

@EFLS EFLS commented on 2c71843 Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both commands should move away from the user-error here. It could be just a message. Any thoughts?

Agreed! This is not really an error anyway, and should indeed just be a message.

Not sure why the Org-mode check is removed? Shouldn't this be only be butonnized when not in Org-mode?

@protesilaos
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! This is not really an error anyway, and should indeed just be a message.

Thanks! I will update them now.

Not sure why the Org-mode check is removed? Shouldn't this be only be butonnized when not in Org-mode?

I thought it was not necessary since denote-link-buttonize-buffer has (when (and (not (derived-mode-p 'org-mode))....

@EFLS
Copy link

@EFLS EFLS commented on 2c71843 Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! All fine by me

Please sign in to comment.