0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:36:26 +00:00

org-table: Fix shrunk columns on hlines

* lisp/org-table.el (org-table--shrunk-field): Fix function when on
  a hline.
* testing/lisp/test-org-table.el (test-org-table/shrunk-columns): Add
  tests.

Reported-by: Kaushal Modi <kaushal.modi@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2018-02/msg00231.html>
This commit is contained in:
Nicolas Goaziou 2018-02-14 18:45:29 +01:00
parent af824a9b39
commit 58da7d4d17
2 changed files with 42 additions and 2 deletions

View file

@ -3842,7 +3842,9 @@ When non-nil, return the overlay narrowing the field."
(and (eq 'table-column-hide (overlay-get o 'org-overlay-type))
o))
(overlays-at (save-excursion
(skip-chars-forward "^|" (line-end-position))
(skip-chars-forward (if (org-at-table-hline-p) "^+|"
"^|")
(line-end-position))
(1- (point))))))
(defun org-table--list-shrunk-columns ()

View file

@ -2591,7 +2591,45 @@ See also `test-org-table/copy-field'."
(org-table-toggle-column-width)
(org-table-get-field nil "b")
(mapcar (lambda (o) (overlay-get o 'help-echo))
(overlays-in (point-min) (point-max)))))))
(overlays-in (point-min) (point-max))))))
;; Moving to next field doesn't change shrunk state.
(should
(equal "a"
(org-test-with-temp-text "| <point>a | b |"
(org-table-toggle-column-width)
(org-table-next-field)
(overlay-get (car (overlays-at (1+ (line-beginning-position))))
'help-echo))))
(should
(equal "b"
(org-test-with-temp-text "| a | <point>b |"
(org-table-toggle-column-width)
(goto-char 2)
(org-table-next-field)
(overlay-get (car (overlays-at (point))) 'help-echo))))
;; Aligning table doesn't alter shrunk state.
(should
(equal "a"
(org-test-with-temp-text "| <point>a | b |"
(org-table-toggle-column-width)
(org-table-align)
(overlay-get (car (overlays-at (1+ (line-beginning-position))))
'help-echo))))
(should
(equal "b"
(org-test-with-temp-text "|---+-----|\n| a | <point>b |"
(org-table-toggle-column-width)
(org-table-align)
(overlay-get (car (overlays-at (point)))
'help-echo))))
(should
(equal
'("b")
(org-test-with-temp-text "|---+-----|\n| a | <point>b |"
(org-table-toggle-column-width)
(org-table-align)
(mapcar (lambda (o) (overlay-get o 'help-echo))
(overlays-in (line-beginning-position) (line-end-position)))))))