EFLS / zetteldeft

A Zettelkasten system! Or rather, some functions on top of the emacs deft package.
https://efls.github.io/zetteldeft
GNU General Public License v3.0
394 stars 42 forks source link

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

Closed localauthor closed 2 years ago

localauthor commented 2 years ago

Fix #29 and #101

cc: @justinmoon @steven-lang

AtomicNess123 commented 2 years ago

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

EFLS commented 2 years ago

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

EFLS commented 2 years ago

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 commented 2 years ago

Too bad... :((

localauthor commented 2 years ago

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

localauthor commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago
zetteldeft-full-search-full-title-insert: works!
zetteldeft-find-file-full-title-insert: wrong type of argument char-or-string-p, nil
localauthor commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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!