Fix bugs wrt invisibility handline.

* org-compat.el (org-move-to-column): Always ignore invisible
text in agenda buffer, and when there is both a bracket link
and '(org-link) as a member of `buffer-invisibility-spec'.
Add a docstring.

* org.el (org-align-tags-here): Add docstring and remove
useless arguments when calling `org-move-to-column'.

* org-table.el (org-table-copy-down)
(org-table-find-dataline, org-table-move-row)
(org-table-insert-hline, org-table-kill-row):
* org-agenda.el (org-agenda-next-item)
(org-agenda-previous-item, org-agenda-todo)
(org-agenda-priority, org-agenda-show-new-time)
(org-agenda-clock-in, org-agenda-clock-out): Remove useless
arguments when calling `org-move-to-column'.

This fixes the issue about S-RET not placing the cursor in the right
table field when M-x org-toggle-link-display RET removed '(org-link)
from `buffer-invisibility-spec' and some other discrepancies (like
S-M-<up> not restoring point correctly when there is a bracket link
before point, or M-x org-clock-display RET not aligning overlays
correctly, etc.

Thanks to Matt Lundin and Michael Brand for tracking issues
about this.
This commit is contained in:
Bastien Guerry 2014-03-20 15:04:49 +01:00
parent 8bab38bcba
commit a3ec854cab
4 changed files with 36 additions and 22 deletions

View File

@ -8275,7 +8275,7 @@ When called with a prefix argument, include all archive files as well."
(when (next-single-property-change (point-at-eol) 'org-marker) (when (next-single-property-change (point-at-eol) 'org-marker)
(move-end-of-line 1) (move-end-of-line 1)
(goto-char (next-single-property-change (point) 'org-marker)))) (goto-char (next-single-property-change (point) 'org-marker))))
(org-move-to-column col nil nil t)) (org-move-to-column col))
(org-agenda-do-context-action)) (org-agenda-do-context-action))
(defun org-agenda-previous-item (n) (defun org-agenda-previous-item (n)
@ -8287,7 +8287,7 @@ When called with a prefix argument, include all archive files as well."
(move-end-of-line 0) (move-end-of-line 0)
(previous-single-property-change (point) 'org-marker)))) (previous-single-property-change (point) 'org-marker))))
(if goto (goto-char goto)) (if goto (goto-char goto))
(org-move-to-column col nil nil t))) (org-move-to-column col)))
(org-agenda-do-context-action)) (org-agenda-do-context-action))
(defun org-agenda-do-context-action () (defun org-agenda-do-context-action ()
@ -8798,7 +8798,7 @@ the same tree node, and the headline of the tree node in the Org-mode file."
(string-match (concat "^" (regexp-opt org-done-keywords-for-agenda)) (string-match (concat "^" (regexp-opt org-done-keywords-for-agenda))
newhead) newhead)
(org-agenda-unmark-clocking-task)) (org-agenda-unmark-clocking-task))
(org-move-to-column col nil nil t)))) (org-move-to-column col))))
(defun org-agenda-add-note (&optional arg) (defun org-agenda-add-note (&optional arg)
"Add a time-stamped note to the entry at point." "Add a time-stamped note to the entry at point."
@ -8954,7 +8954,7 @@ Called with a universal prefix arg, show the priority instead of setting it."
(end-of-line 1) (end-of-line 1)
(setq newhead (org-get-heading))) (setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker) (org-agenda-change-all-lines newhead hdmarker)
(org-move-to-column col nil nil t))))) (org-move-to-column col)))))
;; FIXME: should fix the tags property of the agenda line. ;; FIXME: should fix the tags property of the agenda line.
(defun org-agenda-set-tags (&optional tag onoff) (defun org-agenda-set-tags (&optional tag onoff)
@ -9163,7 +9163,7 @@ Called with a universal prefix arg, show the priority instead of setting it."
(goto-char (point-max)) (goto-char (point-max))
(while (not (bobp)) (while (not (bobp))
(when (equal marker (org-get-at-bol 'org-marker)) (when (equal marker (org-get-at-bol 'org-marker))
(org-move-to-column (- (window-width) (length stamp)) t nil t) (org-move-to-column (- (window-width) (length stamp)) t)
(org-agenda-fix-tags-filter-overlays-at (point)) (org-agenda-fix-tags-filter-overlays-at (point))
(if (featurep 'xemacs) (if (featurep 'xemacs)
;; Use `duplicable' property to trigger undo recording ;; Use `duplicable' property to trigger undo recording
@ -9265,7 +9265,7 @@ ARG is passed through to `org-deadline'."
(org-clock-in arg) (org-clock-in arg)
(setq newhead (org-get-heading))) (setq newhead (org-get-heading)))
(org-agenda-change-all-lines newhead hdmarker)) (org-agenda-change-all-lines newhead hdmarker))
(org-move-to-column col nil nil t)))) (org-move-to-column col))))
(defun org-agenda-clock-out () (defun org-agenda-clock-out ()
"Stop the currently running clock." "Stop the currently running clock."
@ -9285,7 +9285,7 @@ ARG is passed through to `org-deadline'."
(setq newhead (org-get-heading)))))) (setq newhead (org-get-heading))))))
(org-agenda-change-all-lines newhead marker) (org-agenda-change-all-lines newhead marker)
(move-marker marker nil) (move-marker marker nil)
(org-move-to-column col nil nil t) (org-move-to-column col)
(org-agenda-unmark-clocking-task))) (org-agenda-unmark-clocking-task)))
(defun org-agenda-clock-cancel (&optional arg) (defun org-agenda-clock-cancel (&optional arg)

View File

@ -343,10 +343,25 @@ Works on both Emacs and XEmacs."
(org-xemacs-without-invisibility (indent-line-to column)) (org-xemacs-without-invisibility (indent-line-to column))
(indent-line-to column))) (indent-line-to column)))
(defun org-move-to-column (column &optional force buffer ignore-invisible) (defun org-move-to-column (column &optional force buffer)
(let ((buffer-invisibility-spec ignore-invisible)) "Move to column COLUMN.
Pass COLUMN and FORCE to `move-to-column'.
Pass BUFFER to the XEmacs version of `move-to-column'."
(let ((buffer-invisibility-spec
(if (or
;; Ignore all visibility spec in agenda
(not (derived-mode-p 'org-mode))
;; Ignore bracket links elsewere
(and (save-excursion
(forward-line 0)
(looking-at (concat "^.*" org-bracket-link-regexp)))
(member '(org-link)
buffer-invisibility-spec)))
t
buffer-invisibility-spec)))
(if (featurep 'xemacs) (if (featurep 'xemacs)
(org-xemacs-without-invisibility (move-to-column column force buffer)) (org-xemacs-without-invisibility
(move-to-column column force buffer))
(move-to-column column force)))) (move-to-column column force))))
(defun org-get-x-clipboard-compat (value) (defun org-get-x-clipboard-compat (value)

View File

@ -1136,12 +1136,12 @@ copying. In the case of a timestamp, increment by one day."
(< (string-to-number txt) 100000000)) (< (string-to-number txt) 100000000))
(setq txt (format "%d" (+ (string-to-number txt) 1)))) (setq txt (format "%d" (+ (string-to-number txt) 1))))
(insert txt) (insert txt)
(org-move-to-column col nil nil t) (org-move-to-column col)
(if (and org-table-copy-increment (org-at-timestamp-p t)) (if (and org-table-copy-increment (org-at-timestamp-p t))
(org-timestamp-up-day) (org-timestamp-up-day)
(org-table-maybe-recalculate-line)) (org-table-maybe-recalculate-line))
(org-table-align) (org-table-align)
(org-move-to-column col nil nil t)) (org-move-to-column col))
(user-error "No non-empty field found")))) (user-error "No non-empty field found"))))
(defun org-table-check-inside-data-field (&optional noerror) (defun org-table-check-inside-data-field (&optional noerror)
@ -1370,12 +1370,12 @@ However, when FORCE is non-nil, create new columns if necessary."
t t
(let ((col (current-column)) (let ((col (current-column))
(end (org-table-end))) (end (org-table-end)))
(org-move-to-column col nil nil t) (org-move-to-column col)
(while (and (< (point) end) (while (and (< (point) end)
(or (not (= (current-column) col)) (or (not (= (current-column) col))
(org-at-table-hline-p))) (org-at-table-hline-p)))
(beginning-of-line 2) (beginning-of-line 2)
(org-move-to-column col nil nil t)) (org-move-to-column col))
(if (and (org-at-table-p) (if (and (org-at-table-p)
(not (org-at-table-hline-p))) (not (org-at-table-hline-p)))
t t
@ -1524,7 +1524,7 @@ first dline below it is used. When ABOVE is non-nil, the one above is used."
(beginning-of-line tonew) (beginning-of-line tonew)
(insert txt) (insert txt)
(beginning-of-line 0) (beginning-of-line 0)
(org-move-to-column col nil nil t) (org-move-to-column col)
(unless (or hline1p hline2p (unless (or hline1p hline2p
(not (or (not org-table-fix-formulas-confirm) (not (or (not org-table-fix-formulas-confirm)
(funcall org-table-fix-formulas-confirm (funcall org-table-fix-formulas-confirm
@ -1576,7 +1576,7 @@ With prefix ABOVE, insert above the current line."
(beginning-of-line (if above 1 2)) (beginning-of-line (if above 1 2))
(insert line "\n") (insert line "\n")
(beginning-of-line (if above 1 -1)) (beginning-of-line (if above 1 -1))
(org-move-to-column col nil nil t) (org-move-to-column col)
(and org-table-overlay-coordinates (org-table-align)))) (and org-table-overlay-coordinates (org-table-align))))
;;;###autoload ;;;###autoload
@ -1616,7 +1616,7 @@ In particular, this does handle wide and invisible characters."
(dline (org-table-current-dline))) (dline (org-table-current-dline)))
(kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max))) (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
(if (not (org-at-table-p)) (beginning-of-line 0)) (if (not (org-at-table-p)) (beginning-of-line 0))
(org-move-to-column col nil nil t) (org-move-to-column col)
(when (or (not org-table-fix-formulas-confirm) (when (or (not org-table-fix-formulas-confirm)
(funcall org-table-fix-formulas-confirm "Fix formulas? ")) (funcall org-table-fix-formulas-confirm "Fix formulas? "))
(org-table-fix-formulas "@" (list (cons (number-to-string dline) "INVALID")) (org-table-fix-formulas "@" (list (cons (number-to-string dline) "INVALID"))

View File

@ -14403,6 +14403,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
(defun org-align-tags-here (to-col) (defun org-align-tags-here (to-col)
;; Assumes that this is a headline ;; Assumes that this is a headline
"Align tags on the current headline to TO-COL."
(let ((pos (point)) (col (current-column)) ncol tags-l p) (let ((pos (point)) (col (current-column)) ncol tags-l p)
(beginning-of-line 1) (beginning-of-line 1)
(if (and (looking-at (org-re ".*?\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) (if (and (looking-at (org-re ".*?\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"))
@ -14421,7 +14422,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
(insert (make-string (- ncol (current-column)) ?\ )) (insert (make-string (- ncol (current-column)) ?\ ))
(setq ncol (current-column)) (setq ncol (current-column))
(when indent-tabs-mode (tabify p (point-at-eol))) (when indent-tabs-mode (tabify p (point-at-eol)))
(org-move-to-column (min ncol col) t nil t)) (org-move-to-column (min ncol col)))
(goto-char pos)))) (goto-char pos))))
(defun org-set-tags-command (&optional arg just-align) (defun org-set-tags-command (&optional arg just-align)
@ -14480,9 +14481,7 @@ If DATA is nil or the empty string, any tags will be removed."
(defun org-set-tags (&optional arg just-align) (defun org-set-tags (&optional arg just-align)
"Set the tags for the current headline. "Set the tags for the current headline.
With prefix ARG, realign all tags in headings in the current buffer. With prefix ARG, realign all tags in headings in the current buffer.
When JUST-ALIGN is non-nil, only align tags. When JUST-ALIGN is non-nil, only align tags."
When JUST-ALIGN is 'ignore-column, align tags without trying to set
the column by ignoring invisible text."
(interactive "P") (interactive "P")
(if (and (org-region-active-p) org-loop-over-headlines-in-active-region) (if (and (org-region-active-p) org-loop-over-headlines-in-active-region)
(let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level) (let ((cl (if (eq org-loop-over-headlines-in-active-region 'start-level)
@ -14579,7 +14578,7 @@ the column by ignoring invisible text."
(and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point))) (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point)))
tags) tags)
(t (error "Tags alignment failed"))) (t (error "Tags alignment failed")))
(org-move-to-column col nil nil (not (eq just-align 'ignore-column))) (org-move-to-column col)
(unless just-align (unless just-align
(run-hooks 'org-after-tags-change-hook)))))) (run-hooks 'org-after-tags-change-hook))))))