From 722e0e0c83df32fbf0c858beb07d108a48a7c4ce Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 15 Aug 2012 09:35:21 +0200 Subject: [PATCH] Remove `org-substring-no-properties' and some redundant code * org-macs.el (org-no-properties): Allow a new parameter `restricted' to restrict the properties removal to those in `org-rm-props'. The default is now to remove all properties. * org-compat.el (org-substring-no-properties): Remove unused defun. * org-remember.el (org-remember-apply-template): Remove redundant removal of text properties. (org-remember-apply-template): Use `org-no-properties'. * org-capture.el (org-capture-fill-template): Remove redundant removal of text properties. (org-capture-fill-template): Use `org-no-properties'. * org-gnus.el (org-gnus-open, org-gnus-follow-link): Use `org-no-properties'. --- lisp/org-capture.el | 7 +++---- lisp/org-compat.el | 5 ----- lisp/org-gnus.el | 8 ++++---- lisp/org-macs.el | 9 +++++++-- lisp/org-remember.el | 7 +++---- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index e8ce6996a..a59d9ee5b 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1299,8 +1299,7 @@ Lisp programs can force the template by setting KEYS to a string." The template may still contain \"%?\" for cursor positioning." (setq template (or template (org-capture-get :template))) (when (stringp initial) - (setq initial (org-no-properties initial)) - (remove-text-properties 0 (length initial) '(read-only t) initial)) + (setq initial (org-no-properties initial))) (let* ((buffer (org-capture-get :buffer)) (file (buffer-file-name (or (buffer-base-buffer buffer) buffer))) (ct (org-capture-get :default-time)) @@ -1344,7 +1343,7 @@ The template may still contain \"%?\" for cursor positioning." v-a)) (v-n user-full-name) (v-k (if (marker-buffer org-clock-marker) - (org-substring-no-properties org-clock-heading))) + (org-no-properties org-clock-heading))) (v-K (if (marker-buffer org-clock-marker) (org-make-link-string (buffer-file-name (marker-buffer org-clock-marker)) @@ -1477,7 +1476,7 @@ The template may still contain \"%?\" for cursor positioning." '(clipboards . 1) (car clipboards)))))) ((equal char "p") - (org-set-property (org-substring-no-properties prompt) nil)) + (org-set-property (org-no-properties prompt) nil)) (char ;; These are the date/time related ones (setq org-time-was-given (equal (upcase char) char)) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 700355898..1473c24d2 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -331,11 +331,6 @@ Works on both Emacs and XEmacs." string) (apply 'propertize string properties))) -(defun org-substring-no-properties (string &optional from to) - (if (featurep 'xemacs) - (org-no-properties (substring string (or from 0) to)) - (substring-no-properties string from to))) - (defmacro org-find-library-dir (library) `(file-name-directory (locate-library ,library))) diff --git a/lisp/org-gnus.el b/lisp/org-gnus.el index 86c58e15a..de8a00f13 100644 --- a/lisp/org-gnus.el +++ b/lisp/org-gnus.el @@ -233,9 +233,9 @@ If `org-store-link' was called with a prefix arg the meaning of (setq group (match-string 1 path) article (match-string 3 path)) (when group - (setq group (org-substring-no-properties group))) + (setq group (org-no-properties group))) (when article - (setq article (org-substring-no-properties article))) + (setq article (org-no-properties article))) (org-gnus-follow-link group article))) (defun org-gnus-follow-link (&optional group article) @@ -244,9 +244,9 @@ If `org-store-link' was called with a prefix arg the meaning of (funcall (cdr (assq 'gnus org-link-frame-setup))) (if gnus-other-frame-object (select-frame gnus-other-frame-object)) (when group - (setq group (org-substring-no-properties group))) + (setq group (org-no-properties group))) (when article - (setq article (org-substring-no-properties article))) + (setq article (org-no-properties article))) (cond ((and group article) (gnus-activate-group group) (condition-case nil diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 75c4013ed..e99991702 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -239,10 +239,15 @@ We use a macro so that the test can happen at compilation time." s) (match-string-no-properties num string))) -(defsubst org-no-properties (s) +(defsubst org-no-properties (s &optional restricted) + "Remove all text properties from string S. +When RESTRICTED is non-nil, only remove the properties listed +in `org-rm-props'." (if (fboundp 'set-text-properties) (set-text-properties 0 (length s) nil s) - (remove-text-properties 0 (length s) org-rm-props s)) + (if restricted + (remove-text-properties 0 (length s) org-rm-props s) + (set-text-properties 0 (length s) nil s))) s) (defsubst org-get-alist-option (option key) diff --git a/lisp/org-remember.el b/lisp/org-remember.el index 0cc152f7d..7a1eb7762 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -398,8 +398,7 @@ RET at beg-of-buf -> Append to file as level 2 headline This function should be placed into `remember-mode-hook' and in fact requires to be run from that hook to function properly." (when (and (boundp 'initial) (stringp initial)) - (setq initial (org-no-properties initial)) - (remove-text-properties 0 (length initial) '(read-only t) initial)) + (setq initial (org-no-properties initial))) (if org-remember-templates (let* ((entry (org-select-remember-template use-char)) (ct (or org-overriding-default-time (org-current-time))) @@ -446,7 +445,7 @@ to be run from that hook to function properly." v-a)) (v-n user-full-name) (v-k (if (marker-buffer org-clock-marker) - (org-substring-no-properties org-clock-heading))) + (org-no-properties org-clock-heading))) (v-K (if (marker-buffer org-clock-marker) (org-make-link-string (buffer-file-name (marker-buffer org-clock-marker)) @@ -598,7 +597,7 @@ to be run from that hook to function properly." (car clipboards)))))) ((equal char "p") (let* - ((prop (org-substring-no-properties prompt)) + ((prop (org-no-properties prompt)) (pall (concat prop "_ALL")) (allowed (with-current-buffer -- 2.11.4.GIT