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

Add functions to insert IDs or open files based on full text search #127

Merged
merged 11 commits into from
Mar 31, 2022

Conversation

localauthor
Copy link
Contributor

@localauthor localauthor commented Nov 21, 2021

@AtomicNess123
Copy link

I see now this has been pending for a couple months. Can somebody merge it? Thanks!

@EFLS
Copy link
Owner

EFLS commented Feb 4, 2022

Ah yes, lost track of this. I'll do this shortly! Only need to think of a set of default keybindings...

@EFLS
Copy link
Owner

EFLS commented Feb 4, 2022

Also, I ran into an issue where trying to use zetteldeft-full-search-full-title-insert on a note that's in a subdirectory runs into an issue...

The real issue seems be the zetteldeft-find-file-full-title-insert function though, so probably not related to this PR.

@AtomicNess123
Copy link

Too bad... :((

Now accounts for recursive directories, ie, when deft-recursive is non-nil
@localauthor
Copy link
Contributor Author

The problem was actually in my function zetteldeft--full-search. I just pushed a commit that should fix it. Sorry about that!!

@localauthor
Copy link
Contributor Author

Also, @AtomicNess123 , if you want to try out these functions prior to a merge, just to see how they're working for you, you can copy them into a scratch buffer, evaluate them, and call them via M-x.

@AtomicNess123
Copy link

I actually replaced my old zetteldeft.el with the new one and tried the functions and they looked good. Will do more testing today. Thanks!

@AtomicNess123
Copy link

zetteldeft-full-search-full-title-insert: works!
zetteldeft-find-file-full-title-insert: wrong type of argument char-or-string-p, nil

@localauthor
Copy link
Contributor Author

localauthor commented Feb 5, 2022

Strange, since 'full-search' depends on 'find-file'... And both are working fine for me.

Could you do 'toggle-debug-on-error', then try 'zetteldeft-find-file-full-title-insert' again, and paste the backtrace here?

@AtomicNess123
Copy link

Sure, I tried again, same results.
For the error, see below:

insert("§" nil "")
zetteldeft-insert-link-zd-style(nil "The injustice I referred to was the one you indica...")
funcall(zetteldeft-insert-link-zd-style nil "The injustice I referred to was the one you indica...")
zetteldeft--insert-link(nil "The injustice I referred to was the one you indica...")
zetteldeft-find-file-full-title-insert("/textDocument.txt")
funcall-interactively(zetteldeft-find-file-full-title-insert "/textDocument.txt")
call-interactively(zetteldeft-find-file-full-title-insert record nil)
command-execute(zetteldeft-find-file-full-title-insert record)
helm-M-x-execute-command(zetteldeft-find-file-full-title-insert)
helm-execute-selection-action-1()
helm-execute-selection-action()
helm-internal((((name . "Emacs Commands history") (candidates . #f(compiled-function () #<bytecode 0x1ffda5fdaba1>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keep...") (must-match . t) (group . helm-command) (match-dynamic . t)) ((name . "Emacs Commands") (help-current-symbol . zetteldeft-find-file-full-title-insert) (follow . 1) (candidates . #f(compiled-function () #<bytecode 0x1ffda58950bd>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keep...") (must-match . t) (group . helm-command) (match-dynamic . t))) nil "M-x " nil nil "*helm M-x*" nil nil helm-M-x-input-history)
apply(helm-internal ((((name . "Emacs Commands history") (candidates . #f(compiled-function () #<bytecode 0x1ffda5fdaba1>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) (67108989 . helm-narrow-window) (19 . undefined) (24 keymap ... ... ... ... ... ... ... ... ... ... ... ...) (11 . helm-delete-minibuffer-contents) (67108896 . helm-toggle-visible-mark-forward) (0 . helm-toggle-visible-mark) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keeping se...") (must-match . t) (group . helm-command) (match-dynamic . t)) ((name . "Emacs Commands") (help-current-symbol . zetteldeft-find-file-full-title-insert) (follow . 1) (candidates . #f(compiled-function () #<bytecode 0x1ffda58950bd>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) (67108989 . helm-narrow-window) (19 . undefined) (24 keymap ... ... ... ... ... ... ... ... ... ... ... ...) (11 . helm-delete-minibuffer-contents) (67108896 . helm-toggle-visible-mark-forward) (0 . helm-toggle-visible-mark) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keeping se...") (must-match . t) (group . helm-command) (match-dynamic . t))) nil "M-x " nil nil "*helm M-x*" nil nil helm-M-x-input-history))
helm((((name . "Emacs Commands history") (candidates . #f(compiled-function () #<bytecode 0x1ffda5fdaba1>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keep...") (must-match . t) (group . helm-command) (match-dynamic . t)) ((name . "Emacs Commands") (help-current-symbol . zetteldeft-find-file-full-title-insert) (follow . 1) (candidates . #f(compiled-function () #<bytecode 0x1ffda58950bd>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keep...") (must-match . t) (group . helm-command) (match-dynamic . t))) nil "M-x " nil nil "*helm M-x*" nil nil helm-M-x-input-history)
apply(helm ((((name . "Emacs Commands history") (candidates . #f(compiled-function () #<bytecode 0x1ffda5fdaba1>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) (67108989 . helm-narrow-window) (19 . undefined) (24 keymap ... ... ... ... ... ... ... ... ... ... ... ...) (11 . helm-delete-minibuffer-contents) (67108896 . helm-toggle-visible-mark-forward) (0 . helm-toggle-visible-mark) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keeping se...") (must-match . t) (group . helm-command) (match-dynamic . t)) ((name . "Emacs Commands") (help-current-symbol . zetteldeft-find-file-full-title-insert) (follow . 1) (candidates . #f(compiled-function () #<bytecode 0x1ffda58950bd>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) (67108989 . helm-narrow-window) (19 . undefined) (24 keymap ... ... ... ... ... ... ... ... ... ... ... ...) (11 . helm-delete-minibuffer-contents) (67108896 . helm-toggle-visible-mark-forward) (0 . helm-toggle-visible-mark) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keeping se...") (must-match . t) (group . helm-command) (match-dynamic . t))) nil "M-x " nil nil "*helm M-x*" nil nil helm-M-x-input-history))
helm(:sources (((name . "Emacs Commands history") (candidates . #f(compiled-function () #<bytecode 0x1ffda5fdaba1>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keep...") (must-match . t) (group . helm-command) (match-dynamic . t)) ((name . "Emacs Commands") (help-current-symbol . zetteldeft-find-file-full-title-insert) (follow . 1) (candidates . #f(compiled-function () #<bytecode 0x1ffda58950bd>)) (keymap keymap (keymap ...) keymap (21 . helm-M-x-universal-argument) keymap (127 . delete-backward-char) (27 keymap ...) (C-return . helm-cr-empty-string) keymap (f13 lambda nil ... ...) (f12 lambda nil ... ...) (f11 lambda nil ... ...) (f10 lambda nil ... ...) (f9 lambda nil ... ...) (f8 lambda nil ... ...) (f7 lambda nil ... ...) (f6 lambda nil ... ...) (f5 lambda nil ... ...) (f4 lambda nil ... ...) (f3 lambda nil ... ...) (f2 lambda nil ... ...) (menu-bar keymap ...) (help keymap ...) (23 . #f(compiled-function () ... #<bytecode 0x1ffda4065d69>)) (f1 lambda nil ... ...) (8 keymap ... ... ... ... ...) (20 . helm-toggle-resplit-and-swap-windows) (C-tab . undefined) (67108897 . helm-toggle-suspend-update) (3 keymap ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (67108987 . helm-enlarge-window) ...) (action . helm-type-command-actions) (persistent-action . helm-M-x-persistent-action) (persistent-help . "Describe this command") (help-message . helm-M-x-help-message) (requires-pattern . 0) (filtered-candidate-transformer helm-M-x-transformer-no-sort helm-fuzzy-highlight-matches) (volatile . t) (match . identity) (redisplay . identity) (nomark . t) (coerce . helm-symbolify) (header-line . "C-j: Describe this command (keep...") (must-match . t) (group . helm-command) (match-dynamic . t))) :prompt "M-x " :buffer "*helm M-x*" :history helm-M-x-input-history)
helm-M-x-read-extended-command([jupyter-runtime-directory org-brain-show-icons emms-player-fluidsynth-parameters eval-sexp-fu-flash-error reftex-untie-multifile-symbols copy-epl-upgrade nxml-fontify-matcher jupyter-server-kernel-names undo-tree-id811 reftex-default-bibliography names-min pdf-cache-pagelinks citeproc-citation-capitalize-first--cmacro undo-tree-id816 major-mode-hydra--name-for org-brain-visualize-add-grandparent filetree-version biblio--selection-insert none-but-delete ido-choice-list doom-modeline-eldoc-bar sgml-syntax-propertize emms-lyrics-dir elpy-insert--generic-button-action cl-print--preprocess semantic--tag-unlink-list-from-buffer tls-success ellipses found-ids vc-git-conflicted-files undo-tree-id827 jedi:-virtualenv-version firstname jupyter-repl-prompt-margin-width \" force-loc treemacs-workspace-p--cmacro time-format container \' ---5 undo-tree-id832 org-ref-notes-directory citeproc-proc-p--cmacro sessions tramp-gvfs-unmount kdm/html2org-clipboard define-mode-local-override elpy-autodoc--show-doc item-vv ...])
helm-M-x(nil)
funcall-interactively(helm-M-x nil)
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)

@localauthor
Copy link
Contributor Author

The problem is that the file ("textDocument.txt") doesn't have a zetteldeft ID in the filename. So zetteldeft--insert-link returns nil, instead of a string.

@AtomicNess123
Copy link

The problem is that the file ("textDocument.txt") doesn't have a zetteldeft ID in the filename. So zetteldeft--insert-link returns nil, instead of a string.

Am I silly or am I silly? :) Thanks! Tried selecting a proper file name and works.

@EFLS
Copy link
Owner

EFLS commented Mar 31, 2022

Finally got around to this, with a terrible delay.

These new functions are bound to C-c d C-o, C-i and C-I by default.

Thanks for your contribution!

@EFLS EFLS merged commit 9309bdb into EFLS:master Mar 31, 2022
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

Successfully merging this pull request may close these issues.

Insert ID by searching for a term
3 participants