summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-02-04 16:32:34 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-02-04 16:32:34 +0100
commitdc5d61f03ad278a49a52410788e1b5435a011603 (patch)
tree863723be4b1d8d5eb6818c3c1f33136abb0546a9
parent9e2a3cfe9b179c2c5391d0be2e1ad6ecd50662a6 (diff)
downloadorg-mode-dc5d61f03ad278a49a52410788e1b5435a011603.tar.gz
Fix special C-a and C-e behaviour with visual lines
* lisp/org.el (org-beginning-of-line, org-end-of-line): Fix special C-a and C-e behaviour with visual lines.
-rw-r--r--lisp/org.el35
1 files changed, 26 insertions, 9 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 4af7418..05597f8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20404,14 +20404,28 @@ beyond the end of the headline."
((not (eq last-command this-command)) (point))
(t refpos)))))
((org-at-item-p)
- (goto-char
- (if (eq special t)
- (cond ((> pos (match-end 0)) (match-end 0))
- ((= pos (point)) (match-end 0))
- (t (point)))
- (cond ((> pos (point)) (point))
- ((not (eq last-command this-command)) (point))
- (t (match-end 0))))))))
+ ;; Being at an item and not looking at an the item means point
+ ;; was previously moved to beginning of a visual line, whiche
+ ;; doesn't contain the item. Therefore, do nothing special,
+ ;; just stay here.
+ (when (looking-at org-list-full-item-re)
+ ;; Set special position at first white space character after
+ ;; bullet, and check-box, if any.
+ (let ((after-bullet
+ (let ((box (match-end 3)))
+ (if (not box) (match-end 1)
+ (let ((after (char-after box)))
+ (if (and after (= after ? )) (1+ box) box))))))
+ ;; Special case: Move point to special position when
+ ;; currently after it or at beginning of line.
+ (if (eq special t)
+ (when (or (> pos after-bullet) (= (point) pos))
+ (goto-char after-bullet))
+ ;; Reversed case: Move point to special position when
+ ;; point was already at beginning of line and command is
+ ;; repeated.
+ (when (and (= (point) pos) (eq last-command this-command))
+ (goto-char after-bullet))))))))
(org-no-warnings
(and (featurep 'xemacs) (setq zmacs-region-stays t)))))
@@ -20450,7 +20464,10 @@ beyond the end of the headline."
(move-end-of-line 1)
(when (overlays-at (1- (point))) (backward-char 1)))
;; At an item: Move before any hidden text.
- (t (call-interactively 'end-of-line)))
+ (t (call-interactively
+ (cond ((org-bound-and-true-p line-move-visual) 'end-of-visual-line)
+ ((fboundp 'move-end-of-line) 'move-end-of-line)
+ (t 'end-of-line)))))
(org-no-warnings
(and (featurep 'xemacs) (setq zmacs-region-stays t)))))