emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Helm <nick@tenpoint.co.nz>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: 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	[thread overview]
Message-ID: <m2ef80ub41.fsf@tenpoint.co.nz> (raw)
In-Reply-To: <xuu64l90ytpk.fsf@gmail.com> (Eric S. Fraga's message of "Tue, 19 Feb 2019 10:10:31 +0000")

Eric S Fraga <esflists@gmail.com> 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)

  parent reply	other threads:[~2019-02-21 20:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15  0:29 Bug: Org 9.2.1 table issues [9.2.1 (9.2.1-dist @ /Users/nick/.emacs.d/lisp/org-9.2.1/)] Nick Helm
2019-02-15 10:50 ` Nicolas Goaziou
2019-02-16  8:48   ` Nick Helm
2019-02-17 17:52     ` Nicolas Goaziou
2019-02-18  8:11       ` Nick Helm
2019-02-18 21:30         ` Nicolas Goaziou
2019-02-18 22:11           ` Nick Helm
2019-02-18 22:44             ` Nicolas Goaziou
2019-02-19  3:16               ` Nick Helm
2019-02-19 10:10                 ` Eric S Fraga
2019-02-19 11:46                   ` Nick Helm
2019-02-21 20:42                   ` Nick Helm [this message]
2019-02-26 10:10                     ` Eric S Fraga
2019-02-19 12:17       ` Nick Helm
2019-02-19 16:07         ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ef80ub41.fsf@tenpoint.co.nz \
    --to=nick@tenpoint.co.nz \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).