diff options
author | Bastien Guerry <bzg@altern.org> | 2012-12-24 14:44:21 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2012-12-24 14:44:21 +0100 |
commit | ca4219abc9e3e4da41a719d046d2a08fa7d604f1 (patch) | |
tree | cd61509dfa293d58b9d7e53c8d951f40ca341df6 | |
parent | e6d8ed51b8434046d1e49d4c3f19994d69017780 (diff) | |
download | org-mode-ca4219abc9e3e4da41a719d046d2a08fa7d604f1.tar.gz |
org.el: New command `org-set-property-and-value' bound to `C-c C-x P'
* org.el (org-last-set-property-value): New variable.
(org-read-property-name): Fix dangling parentheses.
(org-set-property-and-value): New command to manually set
both the property and the value. A prefix arg will use the
last property-value pair set without prompting the user.
(org-set-property): Set `org-last-set-property-value'.
(org-mode-map): Bind the new command to `C-c C-x P'.
This is useful when you need to set the same property-value
pair for several entries.
-rw-r--r-- | lisp/org.el | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el index 8eb7733..ee4c70e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15083,6 +15083,7 @@ This is computed according to `org-property-set-functions-alist'." val))) (defvar org-last-set-property nil) +(defvar org-last-set-property-value nil) (defun org-read-property-name () "Read a property name." (let* ((completion-ignore-case t) @@ -15100,8 +15101,7 @@ This is computed according to `org-property-set-functions-alist'." ": ") (mapcar 'list keys) nil nil nil nil - default-prop - ))) + default-prop))) (if (member property keys) property (or (cdr (assoc (downcase property) @@ -15109,6 +15109,23 @@ This is computed according to `org-property-set-functions-alist'." keys))) property)))) +(defun org-set-property-and-value (use-last) + "Allow to set [PROPERTY]: [value] direction from prompt. +When use-default, don't even ask, just use the last +\"[PROPERTY]: [value]\" string from the history." + (interactive "P") + (let* ((completion-ignore-case t) + (pv (or (and use-last org-last-set-property-value) + (org-completing-read + "Enter a \"[Property]: [value]\" pair: " + nil nil nil nil nil + org-last-set-property-value))) + prop val) + (when (string-match "^[ \t]*\\([^:]+\\):[ \t]*\\(.*\\)[ \t]*$" pv) + (setq prop (match-string 1 pv) + val (match-string 2 pv)) + (org-set-property prop val)))) + (defun org-set-property (property value) "In the current entry, set PROPERTY to VALUE. When called interactively, this will prompt for a property name, offering @@ -15121,6 +15138,7 @@ in the current file." (value (or value (org-read-property-value property))) (fn (cdr (assoc property org-properties-postprocess-alist)))) (setq org-last-set-property property) + (setq org-last-set-property-value (concat property ": " value)) ;; Possibly postprocess the inserted value: (when fn (setq value (funcall fn value))) (unless (equal (org-entry-get nil property) value) @@ -18392,6 +18410,7 @@ BEG and END default to the buffer boundaries." (org-defkey org-mode-map "\C-c\C-x\\" 'org-toggle-pretty-entities) (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox) (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property) +(org-defkey org-mode-map "\C-c\C-xP" 'org-set-property-and-value) (org-defkey org-mode-map "\C-c\C-xe" 'org-set-effort) (org-defkey org-mode-map "\C-c\C-xE" 'org-inc-effort) (org-defkey org-mode-map "\C-c\C-xo" 'org-toggle-ordered-property) |