Small refactoring

* lisp/org.el (org-macro-initialize-templates): Small refactoring.
This commit is contained in:
Nicolas Goaziou 2012-09-01 11:50:51 +02:00
parent ea77b2ccb2
commit 06bffa9120
1 changed files with 29 additions and 30 deletions

View File

@ -20938,20 +20938,19 @@ Templates are stored in buffer-local variable
function installs the following ones: \"property\", \"date\",
\"time\". and, if appropriate, \"input-file\" and
\"modification-time\"."
(org-with-wide-buffer
(goto-char (point-min))
(let ((case-fold-search t)
(set-template
(lambda (cell)
;; Add CELL to `org-macro-templates' if there's no
;; association matching its CAR already. Otherwise,
;; replace old association with CELL.
(let* ((value (cdr cell))
(key (car cell))
(old-template (assoc key org-macro-templates)))
(if old-template (setcdr old-template value)
;; association matching its name already. Otherwise,
;; replace old association with the new one in that
;; variable.
(let ((old-template (assoc (car cell) org-macro-templates)))
(if old-template (setcdr old-template (cdr cell))
(push cell org-macro-templates))))))
;; Install buffer-local macros.
(org-with-wide-buffer
(goto-char (point-min))
(while (re-search-forward "^[ \t]*#\\+MACRO:" nil t)
(let ((element (org-element-at-point)))
(when (eq (org-element-type element) 'keyword)
@ -20959,7 +20958,7 @@ function installs the following ones: \"property\", \"date\",
(when (string-match "^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$" value)
(funcall set-template
(cons (match-string 1 value)
(or (match-string 2 value) ""))))))))
(or (match-string 2 value) "")))))))))
;; Install hard-coded macros.
(mapc (lambda (cell) (funcall set-template cell))
(list
@ -20974,7 +20973,7 @@ function installs the following ones: \"property\", \"date\",
(cons "modification-time"
(format "(eval (format-time-string \"$1\" '%s))"
(prin1-to-string
(nth 5 (file-attributes visited-file))))))))))))
(nth 5 (file-attributes visited-file)))))))))))
;;; Indentation