Kungsgeten / yankpad

Paste snippets from an org-mode file
MIT License
216 stars 18 forks source link

Yankpad show repeated snippets #77

Closed Randy1Burrell closed 3 years ago

Randy1Burrell commented 3 years ago

This is a really handy package for org-mode users. However, whenever I invoke the function yankpad-insert I see repetitions of the snippets I currently have for the mode I am in.

Notice in the picture of the options that gets displayed are repeated options.

image

Here is my Yankpad configuration:

(use-package yankpad
  :config
  (bind-key "<f9>" 'yankpad-map)
  (bind-key "<f12>" 'yankpad-expand)
  (bind-key "C-c s" 'yankpad-insert))

Though it's not a critical bug, it's annoying and any solution would be appreciated.

Kungsgeten commented 3 years ago

Hi! Happy to hear that you enjoy the package. Could you post your yankpad-file? I haven't had this problem myself.

Randy1Burrell commented 3 years ago

Yeah mon (Jamaican Voice) nice work. The problem seems to have mysteriously disappeared after deleting two of the three snippets I had.

Here's what my yankpad.org file looked like:

* emacs-lisp-mode
** use-package
(use-package $0)
** function
(defun $0)
** package-install
(unless (package-installed-p '${0})
   (package-install '$0))

While I have you here, there is another small query that you might be able to help me with. Are there anyway to do mirroring in the snippets? yasnippet has this feature, but I haven't been able to get it to work in Yankpad. An example of what I was trying is in the package-install snippet above.

Randy1Burrell commented 3 years ago

The bug has returned. After using Yankpad for the past few days I have found that this bug occurs when I have snippets for multiple modes.

Here's my current Yankpad file:

snippets when in emacs-lisp-mode

image

snippets when in org-mode

image
AloisJanicek commented 3 years ago

This has to be related to ivy because when you disable ivy-mode, yankpad items in emacs' built-in completing-read interface aren't doubled as they are in ivy interface.

I verified this on emacs 28 with heavily customized doom, on emacs 27 with vanilla doom and also on vanilla emacs 27 config.

edit: Tracing this down, yankpad-active-snippets returns doubled items and completing-read just hides them but ivy set by global ivy-mode doesn't filter non-unique items out. Going further down it seems like something undesirable is happening in yankpad-set-active-snippets.

edit2: I think this line https://github.com/Kungsgeten/yankpad/blob/06d85f04133fbd49a6469174032f4c10a0abe98d/yankpad.el#L268 effectively doubles the yankpad candidates

Kungsgeten commented 3 years ago

@AloisJanicek Thanks you for bug searching!

Kungsgeten commented 3 years ago

The bug was introduced in #75, but should be fixed now. Sorry for not noticing earlier @Randy1Burrell, I hadn't pulled the Github version into my local branch.