whitespace

This commit is contained in:
Phuntsok Drak-pa 2019-10-21 01:26:32 +02:00
parent 47719bfec1
commit 8d8bf4c814

View File

@ -805,7 +805,6 @@ dump."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(with-eval-after-load 'org (with-eval-after-load 'org
;; custom org functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; custom org functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ck/org-confirm-babel-evaluate (lang body) (defun ck/org-confirm-babel-evaluate (lang body)
(not (or (string= lang "latex") (string= lang "maxima")))) (not (or (string= lang "latex") (string= lang "maxima"))))
@ -813,8 +812,8 @@ dump."
;; custom IDs when exporting ;; custom IDs when exporting
;; inspired by ;; inspired by
;; https://writequit.org/articles/emacs-org-mode-generate-ids.html ;; https://writequit.org/articles/emacs-org-mode-generate-ids.html
(defun eos/org-id-new (&optional prefix) (defun eos/org-id-new (&optional prefix)
"Create a new globally unique ID. "Create a new globally unique ID.
An ID consists of two parts separated by a colon: An ID consists of two parts separated by a colon:
- a prefix - a prefix
@ -827,54 +826,54 @@ variable `org-id-prefix'. However, if PREFIX is the symbol
one. one.
So a typical ID could look like \"Org-4nd91V40HI\"." So a typical ID could look like \"Org-4nd91V40HI\"."
(let* ((prefix (if (eq prefix 'none) (let* ((prefix (if (eq prefix 'none)
"" ""
(concat (or prefix org-id-prefix) "-"))) (concat (or prefix org-id-prefix) "-")))
unique) unique)
(if (equal prefix "-") (setq prefix "")) (if (equal prefix "-") (setq prefix ""))
(cond (cond
((memq org-id-method '(uuidgen uuid)) ((memq org-id-method '(uuidgen uuid))
(setq unique (org-trim (shell-command-to-string org-id-uuid-program))) (setq unique (org-trim (shell-command-to-string org-id-uuid-program)))
(unless (org-uuidgen-p unique) (unless (org-uuidgen-p unique)
(setq unique (org-id-uuid)))) (setq unique (org-id-uuid))))
((eq org-id-method 'org) ((eq org-id-method 'org)
(let* ((etime (org-reverse-string (org-id-time-to-b36))) (let* ((etime (org-reverse-string (org-id-time-to-b36)))
(postfix (if org-id-include-domain (postfix (if org-id-include-domain
(progn (progn
(require 'message) (require 'message)
(concat "@" (message-make-fqdn)))))) (concat "@" (message-make-fqdn))))))
(setq unique (concat etime postfix)))) (setq unique (concat etime postfix))))
(t (error "Invalid `org-id-method'"))) (t (error "Invalid `org-id-method'")))
(concat prefix unique))) (concat prefix unique)))
(defun eos/org-custom-id-get (&optional pom create prefix) (defun eos/org-custom-id-get (&optional pom create prefix)
"Get the CUSTOM_ID property of the entry at point-or-marker POM. "Get the CUSTOM_ID property of the entry at point-or-marker POM.
If POM is nil, refer to the entry at point. If the entry does If POM is nil, refer to the entry at point. If the entry does
not have an CUSTOM_ID, the function returns nil. However, when not have an CUSTOM_ID, the function returns nil. However, when
CREATE is non nil, create a CUSTOM_ID if none is present CREATE is non nil, create a CUSTOM_ID if none is present
already. PREFIX will be passed through to `eos/org-id-new'. In already. PREFIX will be passed through to `eos/org-id-new'. In
any case, the CUSTOM_ID of the entry is returned." any case, the CUSTOM_ID of the entry is returned."
(interactive) (interactive)
(org-with-point-at pom (org-with-point-at pom
(let ((id (org-entry-get nil "CUSTOM_ID"))) (let ((id (org-entry-get nil "CUSTOM_ID")))
(cond (cond
((and id (stringp id) (string-match "\\S-" id)) ((and id (stringp id) (string-match "\\S-" id))
id) id)
(create (create
(setq id (eos/org-id-new (concat prefix "h"))) (setq id (eos/org-id-new (concat prefix "h")))
(org-entry-put pom "CUSTOM_ID" id) (org-entry-put pom "CUSTOM_ID" id)
(org-id-add-location id (buffer-file-name (buffer-base-buffer))) (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
id))))) id)))))
(defun eos/org-add-ids-to-headlines-in-file () (defun eos/org-add-ids-to-headlines-in-file ()
"Add CUSTOM_ID properties to all headlines in the current "Add CUSTOM_ID properties to all headlines in the current
file which do not already have one. Only adds ids if the file which do not already have one. Only adds ids if the
`auto-id' option is set to `t' in the file somewhere. ie, `auto-id' option is set to `t' in the file somewhere. ie,
#+OPTIONS: auto-id:t" #+OPTIONS: auto-id:t"
(interactive) (interactive)
(save-excursion (save-excursion
(widen) (widen)
(goto-char (point-min)) (goto-char (point-min))
(when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t) (when (re-search-forward "^#\\+OPTIONS:.*auto-id:t" (point-max) t)
(org-map-entries (lambda () (eos/org-custom-id-get (point) 'create)))))) (org-map-entries (lambda () (eos/org-custom-id-get (point) 'create))))))
;; org-babel languages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; org-babel languages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(org-babel-do-load-languages (org-babel-do-load-languages
@ -892,13 +891,13 @@ So a typical ID could look like \"Org-4nd91V40HI\"."
(shell . t))) (shell . t)))
;; org hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; org hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'org-mode-hook (add-hook 'org-mode-hook
(lambda () (lambda ()
(add-hook 'before-save-hook (add-hook 'before-save-hook
(lambda () (lambda ()
(when (and (eq major-mode 'org-mode) (when (and (eq major-mode 'org-mode)
(eq buffer-read-only nil)) (eq buffer-read-only nil))
(eos/org-add-ids-to-headlines-in-file)))))) (eos/org-add-ids-to-headlines-in-file))))))
;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq (setq
@ -984,8 +983,6 @@ So a typical ID could look like \"Org-4nd91V40HI\"."
"langue-phundrak-fr-pdf")))) "langue-phundrak-fr-pdf"))))
;; Shortcuts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Shortcuts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(with-eval-after-load 'org-agenda (with-eval-after-load 'org-agenda
(require 'org-projectile) (require 'org-projectile)
(mapcar #'(lambda (file) (mapcar #'(lambda (file)