Browse Source

Merge branch 'org-no-properties'

Bastien Guerry 13 years ago
parent
commit
cacb08334a

+ 1 - 1
lisp/ob-exp.el

@@ -194,7 +194,7 @@ this template."
 				      org-babel-default-lob-header-args
 				      org-babel-default-lob-header-args
 				      (org-babel-params-from-properties)
 				      (org-babel-params-from-properties)
 				      (org-babel-parse-header-arguments
 				      (org-babel-parse-header-arguments
-				       (org-babel-clean-text-properties
+				       (org-no-properties
 					(concat ":var results="
 					(concat ":var results="
 						(mapconcat #'identity
 						(mapconcat #'identity
 							   (butlast lob-info)
 							   (butlast lob-info)

+ 2 - 2
lisp/ob-lob.el

@@ -105,7 +105,7 @@ if so then run the appropriate source block from the Library."
       (beginning-of-line 1)
       (beginning-of-line 1)
       (when (looking-at org-babel-lob-one-liner-regexp)
       (when (looking-at org-babel-lob-one-liner-regexp)
 	(append
 	(append
-	 (mapcar #'org-babel-clean-text-properties
+	 (mapcar #'org-no-properties
 		 (list
 		 (list
 		  (format "%s%s(%s)%s"
 		  (format "%s%s(%s)%s"
 			  (funcall nonempty 3 12)
 			  (funcall nonempty 3 12)
@@ -124,7 +124,7 @@ if so then run the appropriate source block from the Library."
 		      org-babel-default-header-args
 		      org-babel-default-header-args
 		      (org-babel-params-from-properties)
 		      (org-babel-params-from-properties)
 		      (org-babel-parse-header-arguments
 		      (org-babel-parse-header-arguments
-		       (org-babel-clean-text-properties
+		       (org-no-properties
 			(concat ":var results="
 			(concat ":var results="
 				(mapconcat #'identity (butlast info) " "))))))
 				(mapconcat #'identity (butlast info) " "))))))
 	 (pre-info (funcall mkinfo pre-params))
 	 (pre-info (funcall mkinfo pre-params))

+ 1 - 1
lisp/ob-table.el

@@ -99,7 +99,7 @@ as shown in the example below.
 				      (prog1 nil (setq quote t))
 				      (prog1 nil (setq quote t))
 				    (prog1 (if quote
 				    (prog1 (if quote
 					       (format "\"%s\"" el)
 					       (format "\"%s\"" el)
-					     (org-babel-clean-text-properties el))
+					     (org-no-properties el))
 				      (setq quote nil))))
 				      (setq quote nil))))
 				(cdr var)))))
 				(cdr var)))))
 	     variables)))
 	     variables)))

+ 2 - 2
lisp/ob-tangle.el

@@ -374,7 +374,7 @@ code blocks by language."
 		   (link ((lambda (link)
 		   (link ((lambda (link)
 			    (and (string-match org-bracket-link-regexp link)
 			    (and (string-match org-bracket-link-regexp link)
 				 (match-string 1 link)))
 				 (match-string 1 link)))
-			  (org-babel-clean-text-properties
+			  (org-no-properties
 			   (org-store-link nil))))
 			   (org-store-link nil))))
 		   (source-name
 		   (source-name
 		    (intern (or (nth 4 info)
 		    (intern (or (nth 4 info)
@@ -441,7 +441,7 @@ code blocks by language."
   (let* ((start-line (org-babel-where-is-src-block-head))
   (let* ((start-line (org-babel-where-is-src-block-head))
 	 (file (buffer-file-name))
 	 (file (buffer-file-name))
 	 (link (org-link-escape (progn (call-interactively 'org-store-link)
 	 (link (org-link-escape (progn (call-interactively 'org-store-link)
-				       (org-babel-clean-text-properties
+				       (org-no-properties
 					(car (pop org-stored-links))))))
 					(car (pop org-stored-links))))))
 	 (source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
 	 (source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
 	 (link-data (mapcar (lambda (el)
 	 (link-data (mapcar (lambda (el)

+ 11 - 16
lisp/ob.el

@@ -254,7 +254,7 @@ Returns a list
 		   (nth 2 info)
 		   (nth 2 info)
 		   (org-babel-parse-header-arguments (match-string 1)))))
 		   (org-babel-parse-header-arguments (match-string 1)))))
 	  (when (looking-at org-babel-src-name-w-name-regexp)
 	  (when (looking-at org-babel-src-name-w-name-regexp)
-	    (setq name (org-babel-clean-text-properties (match-string 3)))
+	    (setq name (org-no-properties (match-string 3)))
 	    (when (and (match-string 5) (> (length (match-string 5)) 0))
 	    (when (and (match-string 5) (> (length (match-string 5)) 0))
 	      (setf (nth 2 info) ;; merge functional-syntax vars and header-args
 	      (setf (nth 2 info) ;; merge functional-syntax vars and header-args
 		    (org-babel-merge-params
 		    (org-babel-merge-params
@@ -661,7 +661,7 @@ arguments and pop open the results in a preview buffer."
     (dolist (header (mapcar (lambda (arg) (substring (symbol-name (car arg)) 1))
     (dolist (header (mapcar (lambda (arg) (substring (symbol-name (car arg)) 1))
 			    (and (org-babel-where-is-src-block-head)
 			    (and (org-babel-where-is-src-block-head)
 				 (org-babel-parse-header-arguments
 				 (org-babel-parse-header-arguments
-				  (org-babel-clean-text-properties
+				  (org-no-properties
 				   (match-string 4))))))
 				   (match-string 4))))))
       (dolist (name names)
       (dolist (name names)
 	(when (and (not (string= header name))
 	(when (and (not (string= header name))
@@ -1061,7 +1061,7 @@ the current subtree."
 (defun org-babel-current-result-hash ()
 (defun org-babel-current-result-hash ()
   "Return the current in-buffer hash."
   "Return the current in-buffer hash."
   (org-babel-where-is-src-block-result)
   (org-babel-where-is-src-block-result)
-  (org-babel-clean-text-properties (match-string 3)))
+  (org-no-properties (match-string 3)))
 
 
 (defun org-babel-set-current-result-hash (hash)
 (defun org-babel-set-current-result-hash (hash)
   "Set the current in-buffer hash to HASH."
   "Set the current in-buffer hash to HASH."
@@ -1223,10 +1223,10 @@ may be specified in the properties of the current outline entry."
 (defun org-babel-parse-src-block-match ()
 (defun org-babel-parse-src-block-match ()
   "Parse the results from a match of the `org-babel-src-block-regexp'."
   "Parse the results from a match of the `org-babel-src-block-regexp'."
   (let* ((block-indentation (length (match-string 1)))
   (let* ((block-indentation (length (match-string 1)))
-	 (lang (org-babel-clean-text-properties (match-string 2)))
+	 (lang (org-no-properties (match-string 2)))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang)))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang)))
 	 (switches (match-string 3))
 	 (switches (match-string 3))
-         (body (org-babel-clean-text-properties
+         (body (org-no-properties
 		(let* ((body (match-string 5))
 		(let* ((body (match-string 5))
 		       (sub-length (- (length body) 1)))
 		       (sub-length (- (length body) 1)))
 		  (if (and (> sub-length 0)
 		  (if (and (> sub-length 0)
@@ -1248,23 +1248,23 @@ may be specified in the properties of the current outline entry."
            (org-babel-params-from-properties lang)
            (org-babel-params-from-properties lang)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (if (boundp lang-headers) (eval lang-headers) nil)
 	   (org-babel-parse-header-arguments
 	   (org-babel-parse-header-arguments
-            (org-babel-clean-text-properties (or (match-string 4) ""))))
+            (org-no-properties (or (match-string 4) ""))))
 	  switches
 	  switches
 	  block-indentation)))
 	  block-indentation)))
 
 
 (defun org-babel-parse-inline-src-block-match ()
 (defun org-babel-parse-inline-src-block-match ()
   "Parse the results from a match of the `org-babel-inline-src-block-regexp'."
   "Parse the results from a match of the `org-babel-inline-src-block-regexp'."
-  (let* ((lang (org-babel-clean-text-properties (match-string 2)))
+  (let* ((lang (org-no-properties (match-string 2)))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
          (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
     (list lang
     (list lang
           (org-babel-strip-protective-commas
           (org-babel-strip-protective-commas
-           (org-babel-clean-text-properties (match-string 5)) lang)
+           (org-no-properties (match-string 5)) lang)
           (org-babel-merge-params
           (org-babel-merge-params
            org-babel-default-inline-header-args
            org-babel-default-inline-header-args
            (org-babel-params-from-properties lang)
            (org-babel-params-from-properties lang)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (if (boundp lang-headers) (eval lang-headers) nil)
            (org-babel-parse-header-arguments
            (org-babel-parse-header-arguments
-            (org-babel-clean-text-properties (or (match-string 4) "")))))))
+            (org-no-properties (or (match-string 4) "")))))))
 
 
 (defun org-babel-balanced-split (string alts)
 (defun org-babel-balanced-split (string alts)
   "Split STRING on instances of ALTS.
   "Split STRING on instances of ALTS.
@@ -1823,7 +1823,7 @@ If the path of the link is a file path it is expanded using
 `expand-file-name'."
 `expand-file-name'."
   (let* ((case-fold-search t)
   (let* ((case-fold-search t)
          (raw (and (looking-at org-bracket-link-regexp)
          (raw (and (looking-at org-bracket-link-regexp)
-                   (org-babel-clean-text-properties (match-string 1))))
+                   (org-no-properties (match-string 1))))
          (type (and (string-match org-link-types-re raw)
          (type (and (string-match org-link-types-re raw)
                     (match-string 1 raw))))
                     (match-string 1 raw))))
     (cond
     (cond
@@ -1891,7 +1891,7 @@ code ---- the results are extracted in the syntax of the source
           optional LANG argument."
           optional LANG argument."
   (if (stringp result)
   (if (stringp result)
       (progn
       (progn
-        (setq result (org-babel-clean-text-properties result))
+        (setq result (org-no-properties result))
         (when (member "file" result-params)
         (when (member "file" result-params)
 	  (setq result (org-babel-result-to-file
 	  (setq result (org-babel-result-to-file
 			result (when (assoc :file-desc (nth 2 info))
 			result (when (assoc :file-desc (nth 2 info))
@@ -2364,11 +2364,6 @@ block but are passed literally to the \"example-block\"."
       (funcall nb-add (buffer-substring index (point-max))))
       (funcall nb-add (buffer-substring index (point-max))))
     new-body))
     new-body))
 
 
-(defun org-babel-clean-text-properties (text)
-  "Strip all properties from text return."
-  (when text
-    (set-text-properties 0 (length text) nil text) text))
-
 (defun org-babel-strip-protective-commas (body &optional lang)
 (defun org-babel-strip-protective-commas (body &optional lang)
   "Strip protective commas from bodies of source blocks."
   "Strip protective commas from bodies of source blocks."
   (with-temp-buffer
   (with-temp-buffer

+ 3 - 4
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."
 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))
-    (remove-text-properties 0 (length initial) '(read-only t) initial))
+    (setq initial (org-no-properties 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))

+ 3 - 4
lisp/org-colview-xemacs.el

@@ -305,10 +305,9 @@ This is the compiled version of the format.")
 		       (and (looking-at "\\(\\**\\)\\(\\* \\)")
 		       (and (looking-at "\\(\\**\\)\\(\\* \\)")
 			    (org-get-level-face 2))))
 			    (org-get-level-face 2))))
          (item (save-match-data
          (item (save-match-data
-                 (org-no-properties
-                  (org-remove-tabs
-                   (buffer-substring-no-properties
-                    (point-at-bol) (point-at-eol))))))
+		 (org-remove-tabs
+		  (buffer-substring-no-properties
+		   (point-at-bol) (point-at-eol)))))
 	 (color (if (featurep 'xemacs)
 	 (color (if (featurep 'xemacs)
                     (save-excursion
                     (save-excursion
                       (beginning-of-line 1)
                       (beginning-of-line 1)

+ 6 - 8
lisp/org-colview.el

@@ -189,15 +189,13 @@ This is the compiled version of the format.")
 			  ;; we'll clean it later…
 			  ;; we'll clean it later…
 			  (if (derived-mode-p 'org-mode)
 			  (if (derived-mode-p 'org-mode)
 			      (save-match-data
 			      (save-match-data
-				(org-no-properties
-				 (org-remove-tabs
-				  (buffer-substring-no-properties
-				   (point-at-bol) (point-at-eol)))))
+				(org-remove-tabs
+				 (buffer-substring-no-properties
+				  (point-at-bol) (point-at-eol))))
 			    ;; In agenda, just get the `txt' property
 			    ;; In agenda, just get the `txt' property
-			    (org-no-properties
-			     (or (org-get-at-bol 'txt)
-				 (buffer-substring
-				  (point) (progn (end-of-line) (point)))))))
+			    (or (org-get-at-bol 'txt)
+				(buffer-substring-no-properties
+				 (point) (progn (end-of-line) (point))))))
 		  (assoc property props))
 		  (assoc property props))
 	    width (or (cdr (assoc property org-columns-current-maxwidths))
 	    width (or (cdr (assoc property org-columns-current-maxwidths))
 		      (nth 2 column)
 		      (nth 2 column)

+ 0 - 5
lisp/org-compat.el

@@ -326,11 +326,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)))
 
 

+ 4 - 4
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)
     (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

+ 7 - 2
lisp/org-macs.el

@@ -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)

+ 3 - 4
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
 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))
-    (remove-text-properties 0 (length initial) '(read-only t) initial))
+    (setq initial (org-no-properties 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

+ 1 - 2
lisp/org-table.el

@@ -2501,8 +2501,7 @@ not overwrite the stored one."
       (setq orig (or (get-text-property 1 :orig-formula formula) "?"))
       (setq orig (or (get-text-property 1 :orig-formula formula) "?"))
       (while (> ndown 0)
       (while (> ndown 0)
 	(setq fields (org-split-string
 	(setq fields (org-split-string
-		      (org-no-properties
-		       (buffer-substring (point-at-bol) (point-at-eol)))
+		      (buffer-substring-no-properties (point-at-bol) (point-at-eol))
 		      " *| *"))
 		      " *| *"))
 	;; replace fields with duration values if relevant
 	;; replace fields with duration values if relevant
 	(if duration
 	(if duration

+ 4 - 5
lisp/org.el

@@ -14450,11 +14450,10 @@ things up because then unnecessary parsing is avoided."
 				(substring (org-match-string-no-properties 1)
 				(substring (org-match-string-no-properties 1)
 					   0 -1))
 					   0 -1))
 			string (if (equal key clockstr)
 			string (if (equal key clockstr)
-				   (org-no-properties
-				    (org-trim
-				     (buffer-substring
-				      (match-beginning 3) (goto-char
-							   (point-at-eol)))))
+				   (org-trim
+				    (buffer-substring-no-properties
+				     (match-beginning 3) (goto-char
+							  (point-at-eol))))
 				 (substring (org-match-string-no-properties 3)
 				 (substring (org-match-string-no-properties 3)
 					    1 -1)))
 					    1 -1)))
 		  ;; Get the correct property name from the key.  This is
 		  ;; Get the correct property name from the key.  This is