From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Helm 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 Message-ID: References: <874l95qq9c.fsf@nicolasgoaziou.fr> <87ftsmti8p.fsf@nicolasgoaziou.fr> <87mumsss1k.fsf@nicolasgoaziou.fr> <874l90son2.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:53823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwvPC-0004MO-Lw for emacs-orgmode@gnu.org; Thu, 21 Feb 2019 15:57:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwvBD-000890-Un for emacs-orgmode@gnu.org; Thu, 21 Feb 2019 15:42:53 -0500 Received: from mail-eopbgr1360112.outbound.protection.outlook.com ([40.107.136.112]:33306 helo=AUS01-ME1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwvBA-00085F-BD for emacs-orgmode@gnu.org; Thu, 21 Feb 2019 15:42:50 -0500 In-Reply-To: (Eric S. Fraga's message of "Tue, 19 Feb 2019 10:10:31 +0000") Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "emacs-orgmode@gnu.org" Eric S Fraga 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)))) =20 -(defun org-table--make-shrinking-overlay (start end display field &optiona= l pre) +(defun org-table--make-shrinking-overlay (start end display field + &optional pre indicator) "Create an overlay to shrink text between START and END. =20 Use string DISPLAY instead of the real text between the two @@ -3955,8 +3956,9 @@ =20 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. =20 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)) =20 @@ -4014,10 +4017,11 @@ ((org-table--shrunk-field) nil) ;already shrunk ((=3D 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 (<=3D 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 (=3D lead 0)) (pred (=3D 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 (=3D 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))))))))) =20 (defun org-table--read-column-selection (select max)