Move `org-fill-template' into "org-macs.el"

* lisp/org.el (org-fill-template): Move function
* lisp/org-macs.el: ...there.
This commit is contained in:
Nicolas Goaziou 2019-03-03 23:46:32 +01:00
parent d4827ea53f
commit ccfea3d8e5
5 changed files with 10 additions and 14 deletions

View File

@ -32,7 +32,6 @@
(declare-function org-element-type "org-element" (element)) (declare-function org-element-type "org-element" (element))
(declare-function org-escape-code-in-string "org-src" (s)) (declare-function org-escape-code-in-string "org-src" (s))
(declare-function org-export-copy-buffer "ox" ()) (declare-function org-export-copy-buffer "ox" ())
(declare-function org-fill-template "org" (template alist))
(declare-function org-in-commented-heading-p "org" (&optional no-inheritance)) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance))
(defvar org-src-preserve-indentation) (defvar org-src-preserve-indentation)

View File

@ -28,7 +28,6 @@
;;; Code: ;;; Code:
(require 'ob) (require 'ob)
(declare-function org-fill-template "org" (template alist))
(declare-function org-table-convert-region "org-table" (declare-function org-table-convert-region "org-table"
(beg0 end0 &optional separator)) (beg0 end0 &optional separator))
(declare-function orgtbl-to-csv "org-table" (table params)) (declare-function orgtbl-to-csv "org-table" (table params))

View File

@ -38,7 +38,6 @@
(declare-function org-before-first-heading-p "org" ()) (declare-function org-before-first-heading-p "org" ())
(declare-function org-element-at-point "org-element" ()) (declare-function org-element-at-point "org-element" ())
(declare-function org-element-type "org-element" (element)) (declare-function org-element-type "org-element" (element))
(declare-function org-fill-template "org" (template alist))
(declare-function org-heading-components "org" ()) (declare-function org-heading-components "org" ())
(declare-function org-id-find "org-id" (id &optional markerp)) (declare-function org-id-find "org-id" (id &optional markerp))
(declare-function org-in-commented-heading-p "org" (&optional no-inheritance)) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance))

View File

@ -1000,6 +1000,16 @@ as-is if removal failed."
(insert code) (insert code)
(if (org-do-remove-indentation n) (buffer-string) code))) (if (org-do-remove-indentation n) (buffer-string) code)))
(defun org-fill-template (template alist)
"Find each %key of ALIST in TEMPLATE and replace it."
(let ((case-fold-search nil))
(dolist (entry (sort (copy-sequence alist)
(lambda (a b) (< (length (car a)) (length (car b))))))
(setq template
(replace-regexp-in-string
(concat "%" (regexp-quote (car entry)))
(or (cdr entry) "") template t t)))
template))
;;; Text properties ;;; Text properties

View File

@ -18818,17 +18818,6 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
(interactive "p") (interactive "p")
(self-insert-command N)) (self-insert-command N))
(defun org-fill-template (template alist)
"Find each %key of ALIST in TEMPLATE and replace it."
(let ((case-fold-search nil))
(dolist (entry (sort (copy-sequence alist)
(lambda (a b) (< (length (car a)) (length (car b))))))
(setq template
(replace-regexp-in-string
(concat "%" (regexp-quote (car entry)))
(or (cdr entry) "") template t t)))
template))
(defun org-quote-vert (s) (defun org-quote-vert (s)
"Replace \"|\" with \"\\vert\"." "Replace \"|\" with \"\\vert\"."
(while (string-match "|" s) (while (string-match "|" s)