emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: Org 9.2.1 table issues [9.2.1 (9.2.1-dist @ /Users/nick/.em


From: Nick Helm
Subject: Re: [O] Bug: Org 9.2.1 table issues [9.2.1 (9.2.1-dist @ /Users/nick/.emacs.d/lisp/org-9.2.1/)]
Date: Thu, 21 Feb 2019 20:42:40 +0000

Eric S Fraga <address@hidden> writes:

> It would be great, for others that may be interested, if you could post
> your solution to this list.

Here's an alternative way to achieve this with today's master.

--- a/lisp/org-table.el 2019-02-21 21:28:34.000000000 +1300
+++ b/lisp/org-table.el 2019-02-21 22:17:04.000000000 +1300
@@ -3945,7 +3945,8 @@
        (when (org-table--shrunk-field) (push column shrunk)))
       (nreverse shrunk))))
 
-(defun org-table--make-shrinking-overlay (start end display field &optional 
pre)
+(defun org-table--make-shrinking-overlay (start end display field
+                                          &optional pre indicator)
   "Create an overlay to shrink text between START and END.
 
 Use string DISPLAY instead of the real text between the two
@@ -3955,8 +3956,9 @@
 
 When optional argument PRE is non-nil, assume the overlay is
 located at the beginning of the field, and prepend
-`org-table-separator-space' to it.  Otherwise, concatenate
-`org-table-shrunk-column-indicator' at its end.
+`org-table-separator-space' to it. Otherwise, concatenate
+optional string INDICATOR at its end. If INDICATOR is omitted or
+nil, `org-table-shrunk-column-indicator' is used instead.
 
 Return the overlay."
   (let ((show-before-edit
@@ -3965,7 +3967,8 @@
           ;; same column.
           (mapc #'delete-overlay
                 (cdr (overlay-get o 'org-table-column-overlays)))))
-       (o (make-overlay start end)))
+       (o (make-overlay start end))
+   (indicator (or indicator org-table-shrunk-column-indicator)))
     (overlay-put o 'insert-behind-hooks (list show-before-edit))
     (overlay-put o 'insert-in-front-hooks (list show-before-edit))
     (overlay-put o 'modification-hooks (list show-before-edit))
@@ -3975,7 +3978,7 @@
     ;; See `org-table-overlay-coordinates'.
     (overlay-put o 'priority 1)
     (let ((d (if pre (concat org-table-separator-space display)
-              (concat display org-table-shrunk-column-indicator))))
+              (concat display indicator))))
       (org-overlay-display o d 'org-table t))
     o))
 
@@ -4014,10 +4017,11 @@
    ((org-table--shrunk-field) nil)     ;already shrunk
    ((= 0 width)                                ;shrink to one character
     (list (org-table--make-shrinking-overlay
-          start end "" (if (eq 'hline contents) "" contents))))
+          start end "" (if (eq 'hline contents) "" contents)
+      nil org-table-shrunk-column-indicator)))
    ((eq contents 'hline)
     (list (org-table--make-shrinking-overlay
-          start end (make-string (1+ width) ?-) "")))
+          start end (make-string (1+ width) ?-) ""  nil "-")))
    ((equal contents "")                        ;no contents to hide
     (list
      (let ((w (org-string-width (buffer-substring start end)))
@@ -4026,8 +4030,11 @@
           (full (+ 2 width)))
        (if (<= w full)
           (org-table--make-shrinking-overlay
-           (1- end) end (make-string (- full w) ?\s) "")
-        (org-table--make-shrinking-overlay (- end (- w full) 1) end "" "")))))
+           (1- end) end (make-string (- full w) ?\s)
+       "" nil org-table-separator-space)
+        (org-table--make-shrinking-overlay
+     (- end (- w full) 1) end "" ""
+     nil org-table-separator-space)))))
    (t
     ;; If the field is not empty, display exactly WIDTH characters.
     ;; It can mean to partly hide the field, or extend it with virtual
@@ -4048,7 +4055,8 @@
        (let ((pre
               (and (> lead 0)
                    (org-table--make-shrinking-overlay
-                    start (+ start lead) "" contents t)))
+                    start (+ start lead) "" contents
+           t org-table-shrunk-column-indicator)))
              (post
               (org-table--make-shrinking-overlay
                ;; Find cut location so that WIDTH characters are
@@ -4069,7 +4077,7 @@
                          ((pred (< width)) (setq upper mean))
                          (_ (setq lower mean)))))
                    upper))
-               end "" contents)))
+               end "" contents nil org-table-shrunk-column-indicator)))
          (if pre (list pre post) (list post))))
        ;; Contents fit it WIDTH characters.  First compute number of
        ;; white spaces needed on each side of contents, then expand or
@@ -4091,24 +4099,28 @@
                  ((or (guard (= lead 0)) (pred (= before))) nil)
                  ((pred (< before))
                   (org-table--make-shrinking-overlay
-                   start (+ start (- lead before)) "" contents t))
+                   start (+ start (- lead before))
+          "" contents t org-table-separator-space))
                  (_
                   (org-table--make-shrinking-overlay
                    start (1+ start)
                    (make-string (- before (1- lead)) ?\s)
-                   contents t))))
+                   contents t org-table-separator-space))))
               (post
                (pcase (1- trail)
                  ((pred (= after))
-                  (org-table--make-shrinking-overlay (1- end) end "" contents))
+                  (org-table--make-shrinking-overlay
+          (1- end) end "" contents
+          nil org-table-separator-space))
                  ((pred (< after))
                   (org-table--make-shrinking-overlay
-                   (+ after (- end trail)) end "" contents))
+                   (+ after (- end trail)) end "" contents
+          nil org-table-separator-space))
                  (_
                   (org-table--make-shrinking-overlay
                    (1- end) end
                    (make-string (- after (1- trail)) ?\s)
-                   contents)))))
+                   contents nil org-table-separator-space)))))
          (if pre (list pre post) (list post)))))))))
 
 (defun org-table--read-column-selection (select max)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]