diff options
author | yaideltg <github.j9jab@aleeas.com> | 2023-05-11 21:02:27 +0200 |
---|---|---|
committer | yaideltg <github.j9jab@aleeas.com> | 2023-05-11 21:02:27 +0200 |
commit | d1f09edab9e71a7f4292096021fdd4c667136918 (patch) | |
tree | 588e1d915c44373c51cbdb1e7eef4a808358c61d /emacs_init | |
parent | 5cd59d5af72ff6a6ccc9d4855632c61927b727ae (diff) | |
download | configuration files-d1f09edab9e71a7f4292096021fdd4c667136918.tar.gz configuration files-d1f09edab9e71a7f4292096021fdd4c667136918.tar.bz2 configuration files-d1f09edab9e71a7f4292096021fdd4c667136918.zip |
my-denote-journal function with help from Protesilaos
Diffstat (limited to 'emacs_init')
-rw-r--r-- | emacs_init/dot_emacs.org | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/emacs_init/dot_emacs.org b/emacs_init/dot_emacs.org index 65a3bc6..c970d84 100644 --- a/emacs_init/dot_emacs.org +++ b/emacs_init/dot_emacs.org @@ -997,8 +997,8 @@ Facilitating the automatic loggin to the IRC server by using auth-source library :bind ("C-c n n" . denote-open-or-create) ("C-c n l" . denote-link-or-create) - ("C-c n b" . denote-link-find-file) - ("C-c n B" . denote-link-backlinks) + ("C-c n B" . denote-link-find-file) + ("C-c n b" . denote-link-backlinks) ) #+end_src @@ -1044,8 +1044,6 @@ function will never succeed in removing the file from the list. Anyhow, the files will be deleted once emacs is closed and reopened, due to the definition of =org-agenda-files= and =org-agenda-file-regexp= (see above). ----------- - #+begin_src emacs-lisp ;; (defvar my-denote-to-agenda-regexp "_project" ;; "Denote file names that are added to the agenda. @@ -1091,11 +1089,22 @@ Define a function to handle the creation of the journal entry: #+begin_src emacs-lisp (defun my-denote-journal () - "Create an entry tagged 'journal' with the date as its title." + "Check if a file containing the given string exists in the + directory and open it in a new buffer. + If the file does not exist, create it with a 'denote' string." (interactive) - (denote - (format-time-string "%A %e %B %Y") ; format the note's name like Tuesday 14 June 2022 - '("journal"))) ; multiple keywords are a list of strings: '("one" "two") + (let* ((string (denote-sluggify (format-time-string "%A %e %B %Y"))) + (files (denote-directory-files-matching-regexp string))) + (cond + ((> (length files) 1) + (find-file (completing-read "Select file: " files nil :require-match))) + (files + (find-file (car files))) + ;; If we reach this point, the file doesn't exist, so we create it + (t + (denote + (format-time-string "%A %e %B %Y") ; format the note's name like Tuesday 14 June 2022 + '("journal")))))) #+end_src Bind it to a keybinding. However, every time you hit this keybinding a new note is going to be created. Have @@ -1105,7 +1114,6 @@ second. I prefer to create them #+begin_src emacs-lisp (global-set-key (kbd "C-c n j") 'my-denote-journal) #+end_src - * Markdown mode #+begin_src emacs-lisp |