Handle correctly `shift-select-mode'

* lisp/org.el (org-beginning-of-line): Handle correctly `shift-select-mode'.

Reported-by: Mathieu Marques <mathieumarques78@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/106783>
This commit is contained in:
Nicolas Goaziou 2016-04-28 23:28:15 +02:00
parent 6ed60a797a
commit 3baf246f4f
1 changed files with 40 additions and 51 deletions

View File

@ -23842,57 +23842,46 @@ beyond the end of the headline."
(car org-special-ctrl-a/e) (car org-special-ctrl-a/e)
org-special-ctrl-a/e)) org-special-ctrl-a/e))
deactivate-mark refpos) deactivate-mark refpos)
(if (org-bound-and-true-p visual-line-mode) (call-interactively (if (org-bound-and-true-p visual-line-mode)
(beginning-of-visual-line 1) #'beginning-of-visual-line
(beginning-of-line 1)) #'move-beginning-of-line))
(if (and arg (fboundp 'move-beginning-of-line)) (cond
(call-interactively 'move-beginning-of-line) ((or arg (not special)))
(unless (bobp) ((and (looking-at org-complex-heading-regexp)
(backward-char 1) (eq (char-after (match-end 1)) ?\s))
(if (org-truely-invisible-p) (setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
(while (and (not (bobp)) (org-truely-invisible-p)) (point-at-eol)))
(backward-char 1) (goto-char
(beginning-of-line 1)) (if (eq special t)
(forward-char 1)))) (cond ((> pos refpos) refpos)
(when special ((= pos (point)) refpos)
(cond (t (point)))
((and (looking-at org-complex-heading-regexp) (cond ((> pos (point)) (point))
(eq (char-after (match-end 1)) ?\s)) ((not (eq last-command this-command)) (point))
(setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1))) (t refpos)))))
(point-at-eol))) ((org-at-item-p)
(goto-char ;; Being at an item and not looking at an the item means point
(if (eq special t) ;; was previously moved to beginning of a visual line, which
(cond ((> pos refpos) refpos) ;; doesn't contain the item. Therefore, do nothing special,
((= pos (point)) refpos) ;; just stay here.
(t (point))) (when (looking-at org-list-full-item-re)
(cond ((> pos (point)) (point)) ;; Set special position at first white space character after
((not (eq last-command this-command)) (point)) ;; bullet, and check-box, if any.
(t refpos))))) (let ((after-bullet
((org-at-item-p) (let ((box (match-end 3)))
;; Being at an item and not looking at an the item means point (if (not box) (match-end 1)
;; was previously moved to beginning of a visual line, which (let ((after (char-after box)))
;; doesn't contain the item. Therefore, do nothing special, (if (and after (= after ? )) (1+ box) box))))))
;; just stay here. ;; Special case: Move point to special position when
(when (looking-at org-list-full-item-re) ;; currently after it or at beginning of line.
;; Set special position at first white space character after (if (eq special t)
;; bullet, and check-box, if any. (when (or (> pos after-bullet) (= (point) pos))
(let ((after-bullet (goto-char after-bullet))
(let ((box (match-end 3))) ;; Reversed case: Move point to special position when
(if (not box) (match-end 1) ;; point was already at beginning of line and command is
(let ((after (char-after box))) ;; repeated.
(if (and after (= after ? )) (1+ box) box)))))) (when (and (= (point) pos) (eq last-command this-command))
;; Special case: Move point to special position when (goto-char after-bullet))))))))
;; 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))))
(setq disable-point-adjustment (setq disable-point-adjustment
(or (not (invisible-p (point))) (or (not (invisible-p (point)))
(not (invisible-p (max (point-min) (1- (point)))))))) (not (invisible-p (max (point-min) (1- (point))))))))