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'.
This commit is contained in:
Bastien Guerry 2012-08-15 09:35:21 +02:00
parent 16ea0364a4
commit 722e0e0c83
5 changed files with 17 additions and 19 deletions

View File

@ -1299,8 +1299,7 @@ Lisp programs can force the template by setting KEYS to a string."
The template may still contain \"%?\" for cursor positioning." The template may still contain \"%?\" for cursor positioning."
(setq template (or template (org-capture-get :template))) (setq template (or template (org-capture-get :template)))
(when (stringp initial) (when (stringp initial)
(setq initial (org-no-properties initial)) (setq initial (org-no-properties initial)))
(remove-text-properties 0 (length initial) '(read-only t) initial))
(let* ((buffer (org-capture-get :buffer)) (let* ((buffer (org-capture-get :buffer))
(file (buffer-file-name (or (buffer-base-buffer buffer) buffer))) (file (buffer-file-name (or (buffer-base-buffer buffer) buffer)))
(ct (org-capture-get :default-time)) (ct (org-capture-get :default-time))
@ -1344,7 +1343,7 @@ The template may still contain \"%?\" for cursor positioning."
v-a)) v-a))
(v-n user-full-name) (v-n user-full-name)
(v-k (if (marker-buffer org-clock-marker) (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) (v-K (if (marker-buffer org-clock-marker)
(org-make-link-string (org-make-link-string
(buffer-file-name (marker-buffer org-clock-marker)) (buffer-file-name (marker-buffer org-clock-marker))
@ -1477,7 +1476,7 @@ The template may still contain \"%?\" for cursor positioning."
'(clipboards . 1) '(clipboards . 1)
(car clipboards)))))) (car clipboards))))))
((equal char "p") ((equal char "p")
(org-set-property (org-substring-no-properties prompt) nil)) (org-set-property (org-no-properties prompt) nil))
(char (char
;; These are the date/time related ones ;; These are the date/time related ones
(setq org-time-was-given (equal (upcase char) char)) (setq org-time-was-given (equal (upcase char) char))

View File

@ -331,11 +331,6 @@ Works on both Emacs and XEmacs."
string) string)
(apply 'propertize string properties))) (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) (defmacro org-find-library-dir (library)
`(file-name-directory (locate-library ,library))) `(file-name-directory (locate-library ,library)))

View File

@ -233,9 +233,9 @@ If `org-store-link' was called with a prefix arg the meaning of
(setq group (match-string 1 path) (setq group (match-string 1 path)
article (match-string 3 path)) article (match-string 3 path))
(when group (when group
(setq group (org-substring-no-properties group))) (setq group (org-no-properties group)))
(when article (when article
(setq article (org-substring-no-properties article))) (setq article (org-no-properties article)))
(org-gnus-follow-link group article))) (org-gnus-follow-link group article)))
(defun org-gnus-follow-link (&optional 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))) (funcall (cdr (assq 'gnus org-link-frame-setup)))
(if gnus-other-frame-object (select-frame gnus-other-frame-object)) (if gnus-other-frame-object (select-frame gnus-other-frame-object))
(when group (when group
(setq group (org-substring-no-properties group))) (setq group (org-no-properties group)))
(when article (when article
(setq article (org-substring-no-properties article))) (setq article (org-no-properties article)))
(cond ((and group article) (cond ((and group article)
(gnus-activate-group group) (gnus-activate-group group)
(condition-case nil (condition-case nil

View File

@ -239,10 +239,15 @@ We use a macro so that the test can happen at compilation time."
s) s)
(match-string-no-properties num string))) (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) (if (fboundp 'set-text-properties)
(set-text-properties 0 (length s) nil s) (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) s)
(defsubst org-get-alist-option (option key) (defsubst org-get-alist-option (option key)

View File

@ -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 This function should be placed into `remember-mode-hook' and in fact requires
to be run from that hook to function properly." to be run from that hook to function properly."
(when (and (boundp 'initial) (stringp initial)) (when (and (boundp 'initial) (stringp initial))
(setq initial (org-no-properties initial)) (setq initial (org-no-properties initial)))
(remove-text-properties 0 (length initial) '(read-only t) initial))
(if org-remember-templates (if org-remember-templates
(let* ((entry (org-select-remember-template use-char)) (let* ((entry (org-select-remember-template use-char))
(ct (or org-overriding-default-time (org-current-time))) (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-a))
(v-n user-full-name) (v-n user-full-name)
(v-k (if (marker-buffer org-clock-marker) (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) (v-K (if (marker-buffer org-clock-marker)
(org-make-link-string (org-make-link-string
(buffer-file-name (marker-buffer org-clock-marker)) (buffer-file-name (marker-buffer org-clock-marker))
@ -598,7 +597,7 @@ to be run from that hook to function properly."
(car clipboards)))))) (car clipboards))))))
((equal char "p") ((equal char "p")
(let* (let*
((prop (org-substring-no-properties prompt)) ((prop (org-no-properties prompt))
(pall (concat prop "_ALL")) (pall (concat prop "_ALL"))
(allowed (allowed
(with-current-buffer (with-current-buffer