[Emacs] Better slug generator for custom IDs, update some CUSTOM_IDs

This commit is contained in:
Lucien Cartier-Tilet 2020-10-25 11:24:04 +01:00
parent 72edabc4f1
commit 24beba2616
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -1369,7 +1369,7 @@
*** ~with-face~ *** ~with-face~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions_macros_and_variables-with-face-60298b14 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-with-face-7974e15f
:END: :END:
~with-face~ is a simple yet very useful macro that allows me to easily ~with-face~ is a simple yet very useful macro that allows me to easily
create strings with faces defined as properties to the string passed as the create strings with faces defined as properties to the string passed as the
@ -1382,7 +1382,7 @@
*** ~phundrak/var-or-if-nil~ *** ~phundrak/var-or-if-nil~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables_-phundrak-var-or-if-nil--5ed18c8f :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-var-or-if-nil-40e2e54a
:END: :END:
This simple function helps me return either the value ~var~ holds, or if it This simple function helps me return either the value ~var~ holds, or if it
is ~nil~ it will return the value ~value~ holds (or will return). is ~nil~ it will return the value ~value~ holds (or will return).
@ -1397,7 +1397,7 @@
*** ~phundrak/abbr-path~ *** ~phundrak/abbr-path~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions_macros_and_variables-phundrakabbr-pwd-5cf1b16d :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-abbr-path-559b46e3
:END: :END:
The following is a nice little function I use in my Eshell prompt. It The following is a nice little function I use in my Eshell prompt. It
shortens the name of all the parent directories of the current one in its shortens the name of all the parent directories of the current one in its
@ -1435,7 +1435,7 @@
*** ~phundrak/prompt-toggle-abbreviation~ *** ~phundrak/prompt-toggle-abbreviation~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions_macros_and_variables-phundrakprompt-toggle-abbreviation-8fcc2389 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-prompt-toggle-abbreviation-753ca549
:END: :END:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defvar phundrak/prompt--abbreviate t (defvar phundrak/prompt--abbreviate t
@ -1451,7 +1451,7 @@
*** ~phundrak/add-all-to-list~ *** ~phundrak/add-all-to-list~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions-phundrakadd-all-to-list-7e34472b :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-add-all-to-list-a8b2680d
:END: :END:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defun phundrak/add-all-to-list ($list &rest $elements) (defun phundrak/add-all-to-list ($list &rest $elements)
@ -1466,7 +1466,7 @@
*** ~phundrak/eshell-git-status~ *** ~phundrak/eshell-git-status~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions_and_variables-phundrakeshell-git-status-7f487b84 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-eshell-git-status-28f16e94
:END: :END:
This function is used in my Eshell prompt which you can consult [[#User_Configuration-Eshell-Eshell_theme-a06715a9][here]]. This This function is used in my Eshell prompt which you can consult [[#User_Configuration-Eshell-Eshell_theme-a06715a9][here]]. This
function basically executes two git calls to get some information about a function basically executes two git calls to get some information about a
@ -1540,7 +1540,7 @@
*** ~phundrak/fill-paragraph~ *** ~phundrak/fill-paragraph~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions-phundrak-fill-paragraph-ab4ef600 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-fill-paragraph-eb568313
:END: :END:
This function was created in order to bind to another keyboard shortcut the This function was created in order to bind to another keyboard shortcut the
already existing ~C-u M-q~ which I cannot type with evil-mode unless Im in already existing ~C-u M-q~ which I cannot type with evil-mode unless Im in
@ -1554,7 +1554,7 @@
*** ~phundrak/find-org-file~ *** ~phundrak/find-org-file~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions-phundrakfind-org-file-029040a5 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-find-org-file-a8fd200f
:END: :END:
There are lots of files which I want to be able to quickly open. I used to There are lots of files which I want to be able to quickly open. I used to
have one shortcut for each one of these files, but as their number grew, I have one shortcut for each one of these files, but as their number grew, I
@ -1593,7 +1593,7 @@
*** ~phundrak/is-dir-a-git-repo~ *** ~phundrak/is-dir-a-git-repo~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions_macros_and_variables-phundrakis-dir-a-git-repo-4dc207d7 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-is-dir-a-git-repo-3bb5e09b
:END: :END:
This function detects if the path passed as an argument points to a git This function detects if the path passed as an argument points to a git
directory or to one of its subdirectories. directory or to one of its subdirectories.
@ -1609,7 +1609,7 @@
*** ~phundrak/yas-rust-new-assignments~ *** ~phundrak/yas-rust-new-assignments~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions-phundrakyas-rust-new-assignments-10f73456 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-phundrak-yas-rust-new-assignments-4ad16bde
:END: :END:
The following function is a function that will allow me to easily create The following function is a function that will allow me to easily create
~new~ functions for Rust structs. Inspired from [[https://github.com/jorgenschaefer/elpy][elpy]]s ~new~ functions for Rust structs. Inspired from [[https://github.com/jorgenschaefer/elpy][elpy]]s
@ -1642,7 +1642,7 @@
*** ~terminal-here-default-terminal-command~ *** ~terminal-here-default-terminal-command~
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: User_Configuration-Custom_functions-terminal-here-default-terminal-command-1916a912 :CUSTOM_ID: User-Configuration-Custom-functions-macros-and-variables-terminal-here-default-terminal-command-9baa3715
:END: :END:
This function is actually an overwrite of the default one which apparently This function is actually an overwrite of the default one which apparently
does not work on my machine. This function is called by does not work on my machine. This function is called by
@ -2105,11 +2105,14 @@
(org-with-point-at pom (org-with-point-at pom
(let* ((orgpath (mapconcat #'identity (org-get-outline-path) "-")) (let* ((orgpath (mapconcat #'identity (org-get-outline-path) "-"))
(heading (replace-regexp-in-string (heading (replace-regexp-in-string
"/\\|\\~\\|,\\|\\\\" "" "[_-]+$" ""
(replace-regexp-in-string (replace-regexp-in-string
" " "_" (if (string= orgpath "") "[-_]+" "-"
(replace-regexp-in-string
"[^a-zA-Z0-9-_]" "-"
(if (string= orgpath "")
(org-get-heading t t t t) (org-get-heading t t t t)
(concat orgpath "-" (org-get-heading t t t t)))))) (concat orgpath "_" (org-get-heading t t t t)))))))
(id (org-entry-get nil "CUSTOM_ID"))) (id (org-entry-get nil "CUSTOM_ID")))
(cond (cond
((and id ((and id
@ -2136,12 +2139,8 @@
(save-excursion (save-excursion
(widen) (widen)
(goto-char (point-min)) (goto-char (point-min))
(when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t)
(point-max) (org-map-entries (lambda () (eos/org-custom-id-get (point) 'create))))))
t)
(org-map-entries (lambda ()
(eos/org-custom-id-get (point)
'create))))))
#+END_SRC #+END_SRC
Lets add a hook to the above function so it is called automatically on Lets add a hook to the above function so it is called automatically on