Browse Source

Move `org-string-width' to "org-macs.el"

* lisp/org.el (org-string-width): Move from here...
* lisp/org-macs.el (org-string-width): ... to here.
Nicolas Goaziou 8 years ago
parent
commit
9a60db0ec3
2 changed files with 21 additions and 21 deletions
  1. 21 0
      lisp/org-macs.el
  2. 0 21
      lisp/org.el

+ 21 - 0
lisp/org-macs.el

@@ -60,6 +60,27 @@ and end of string are ignored."
       (setq string (replace-match "" nil nil string)))
       (setq string (replace-match "" nil nil string)))
     (split-string string separators)))
     (split-string string separators)))
 
 
+(defun org-string-width (s)
+  "Compute width of string S, ignoring invisible characters."
+  (let ((invisiblep (lambda (v)
+		      ;; Non-nil if a V `invisible' property means
+		      ;; that that text is meant to be invisible.
+		      (or (eq t buffer-invisibility-spec)
+			  (assoc-string v buffer-invisibility-spec))))
+	(len (length s)))
+    (let ((invisible-parts nil))
+      (let ((cursor 0))
+	(while (setq cursor (text-property-not-all cursor len 'invisible nil s))
+	  (let ((end (or (next-single-property-change cursor 'invisible s len))))
+	    (when (funcall invisiblep (get-text-property cursor 'invisible s))
+	      (push (cons cursor end) invisible-parts))
+	    (setq cursor end))))
+      (let ((new-string s))
+	(pcase-dolist (`(,begin . ,end) invisible-parts)
+	  (setq new-string (concat (substring new-string 0 begin)
+				   (substring new-string end))))
+	(string-width new-string)))))
+
 (defun org-not-nil (v)
 (defun org-not-nil (v)
   "If V not nil, and also not the string \"nil\", then return V.
   "If V not nil, and also not the string \"nil\", then return V.
 Otherwise return nil."
 Otherwise return nil."

+ 0 - 21
lisp/org.el

@@ -21822,27 +21822,6 @@ If DELETE is non-nil, delete all those overlays."
   (interactive "p")
   (interactive "p")
   (self-insert-command N))
   (self-insert-command N))
 
 
-(defun org-string-width (s)
-  "Compute width of string S, ignoring invisible characters."
-  (let ((invisiblep (lambda (v)
-		      ;; Non-nil if a V `invisible' property means
-		      ;; that that text is meant to be invisible.
-		      (or (eq t buffer-invisibility-spec)
-			  (assoc-string v buffer-invisibility-spec))))
-	(len (length s)))
-    (let ((invisible-parts nil))
-      (let ((cursor 0))
-	(while (setq cursor (text-property-not-all cursor len 'invisible nil s))
-	  (let ((end (or (next-single-property-change cursor 'invisible s len))))
-	    (when (funcall invisiblep (get-text-property cursor 'invisible s))
-	      (push (cons cursor end) invisible-parts))
-	    (setq cursor end))))
-      (let ((new-string s))
-	(pcase-dolist (`(,begin . ,end) invisible-parts)
-	  (setq new-string (concat (substring new-string 0 begin)
-				   (substring new-string end))))
-	(string-width new-string)))))
-
 (defun org-shorten-string (s maxlength)
 (defun org-shorten-string (s maxlength)
   "Shorten string S so that it is no longer than MAXLENGTH characters.
   "Shorten string S so that it is no longer than MAXLENGTH characters.
 If the string is shorter or has length MAXLENGTH, just return the
 If the string is shorter or has length MAXLENGTH, just return the