Editing: Allow separate special settings for C-a and C-e
Alan E. Davis writes: > I have found the behavior of the cursor at the beginning of > the line to be clumsy, and troublesome. I cannot easily set > a region, for example. > > However, the special setting of ctrl-e is extremely useful. > > A single variable controls these two variables, in a unified > way. This variable also has two aliases. The aliases are > not recognized by the functions that are affected by these > variables in org.el: org-beginning-of-line, and > org-end-of-line. As far as I can see, there seems no reason > to keep these two aliased variables as references to a > single unified variable, insofar as the underlying code is > concerned. > > Because, at least for me, the behaviors have sufficiently > distinct behaviors, I propose these should be separated. This is a reasonable request, and this commit implements it. To have separate values, set org-special-ctrl-a/e to a cons cell with the setting for C-a in the car and the setting for C-e in the cdr.
This commit is contained in:
parent
4138be27ba
commit
405186a16a
|
@ -10,6 +10,10 @@
|
|||
(org-add-planning-info): Catch the case when there is no planning
|
||||
info yet and the call does not want to add anything, only maybe
|
||||
tries to remove something.
|
||||
(org-special-ctrl-a/e): All value to be a cons cell with separate
|
||||
settings for `C-a. and `C-e'.
|
||||
(org-beginning-of-line, org-end-of-line): Honor separate values
|
||||
for `C-a' and `C-e'.
|
||||
|
||||
2009-02-21 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
|
|
78
lisp/org.el
78
lisp/org.el
|
@ -650,23 +650,37 @@ body starts at column 0, indentation is not changed at all."
|
|||
|
||||
(defcustom org-special-ctrl-a/e nil
|
||||
"Non-nil means `C-a' and `C-e' behave specially in headlines and items.
|
||||
|
||||
When t, `C-a' will bring back the cursor to the beginning of the
|
||||
headline text, i.e. after the stars and after a possible TODO keyword.
|
||||
In an item, this will be the position after the bullet.
|
||||
When the cursor is already at that position, another `C-a' will bring
|
||||
it to the beginning of the line.
|
||||
|
||||
`C-e' will jump to the end of the headline, ignoring the presence of tags
|
||||
in the headline. A second `C-e' will then jump to the true end of the
|
||||
line, after any tags.
|
||||
|
||||
When set to the symbol `reversed', the first `C-a' or `C-e' works normally,
|
||||
and only a directly following, identical keypress will bring the cursor
|
||||
to the special positions."
|
||||
to the special positions.
|
||||
|
||||
This may also be a cons cell where the behavior for `C-a' and `C-e' is
|
||||
set separately."
|
||||
:group 'org-edit-structure
|
||||
:type '(choice
|
||||
(const :tag "off" nil)
|
||||
(const :tag "after bullet first" t)
|
||||
(const :tag "border first" reversed)))
|
||||
|
||||
(const :tag "after stars/bullet and before tags first" t)
|
||||
(const :tag "true line boundary first" reversed)
|
||||
(cons :tag "Set C-a and C-e separately"
|
||||
(choice :tag "Special C-a"
|
||||
(const :tag "off" nil)
|
||||
(const :tag "after stars/bullet first" t)
|
||||
(const :tag "before stars/bullet first" reversed))
|
||||
(choice :tag "Special C-e"
|
||||
(const :tag "off" nil)
|
||||
(const :tag "before tags first" t)
|
||||
(const :tag "after tags first" reversed)))))
|
||||
(if (fboundp 'defvaralias)
|
||||
(defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e))
|
||||
|
||||
|
@ -15071,7 +15085,11 @@ If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the
|
|||
first attempt, and only move to after the tags when the cursor is already
|
||||
beyond the end of the headline."
|
||||
(interactive "P")
|
||||
(let ((pos (point)) refpos)
|
||||
(let ((pos (point))
|
||||
(special (if (consp org-special-ctrl-a/e)
|
||||
(car org-special-ctrl-a/e)
|
||||
org-special-ctrl-a/e))
|
||||
refpos)
|
||||
(beginning-of-line 1)
|
||||
(if (and arg (fboundp 'move-beginning-of-line))
|
||||
(call-interactively 'move-beginning-of-line)
|
||||
|
@ -15083,14 +15101,14 @@ beyond the end of the headline."
|
|||
(backward-char 1)
|
||||
(beginning-of-line 1))
|
||||
(forward-char 1))))
|
||||
(when org-special-ctrl-a/e
|
||||
(when special
|
||||
(cond
|
||||
((and (looking-at org-complex-heading-regexp)
|
||||
(= (char-after (match-end 1)) ?\ ))
|
||||
(setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
|
||||
(point-at-eol)))
|
||||
(goto-char
|
||||
(if (eq org-special-ctrl-a/e t)
|
||||
(if (eq special t)
|
||||
(cond ((> pos refpos) refpos)
|
||||
((= pos (point)) refpos)
|
||||
(t (point)))
|
||||
|
@ -15099,7 +15117,7 @@ beyond the end of the headline."
|
|||
(t refpos)))))
|
||||
((org-at-item-p)
|
||||
(goto-char
|
||||
(if (eq org-special-ctrl-a/e t)
|
||||
(if (eq special t)
|
||||
(cond ((> pos (match-end 4)) (match-end 4))
|
||||
((= pos (point)) (match-end 4))
|
||||
(t (point)))
|
||||
|
@ -15115,29 +15133,31 @@ If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the
|
|||
first attempt, and only move to after the tags when the cursor is already
|
||||
beyond the end of the headline."
|
||||
(interactive "P")
|
||||
(if (or (not org-special-ctrl-a/e)
|
||||
(not (org-on-heading-p))
|
||||
arg)
|
||||
(call-interactively (if (fboundp 'move-end-of-line)
|
||||
'move-end-of-line
|
||||
'end-of-line))
|
||||
(let ((pos (point)))
|
||||
(beginning-of-line 1)
|
||||
(if (looking-at (org-re ".*?\\([ \t]*\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
|
||||
(if (eq org-special-ctrl-a/e t)
|
||||
(if (or (< pos (match-beginning 1))
|
||||
(= pos (match-end 0)))
|
||||
(goto-char (match-beginning 1))
|
||||
(goto-char (match-end 0)))
|
||||
(if (or (< pos (match-end 0)) (not (eq this-command last-command)))
|
||||
(goto-char (match-end 0))
|
||||
(goto-char (match-beginning 1))))
|
||||
(let ((special (if (consp org-special-ctrl-a/e)
|
||||
(cdr org-special-ctrl-a/e)
|
||||
org-special-ctrl-a/e)))
|
||||
(if (or (not special)
|
||||
(not (org-on-heading-p))
|
||||
arg)
|
||||
(call-interactively (if (fboundp 'move-end-of-line)
|
||||
'move-end-of-line
|
||||
'end-of-line)))))
|
||||
(org-no-warnings
|
||||
(and (featurep 'xemacs) (setq zmacs-region-stays t))))
|
||||
|
||||
'end-of-line))
|
||||
(let ((pos (point)))
|
||||
(beginning-of-line 1)
|
||||
(if (looking-at (org-re ".*?\\([ \t]*\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))
|
||||
(if (eq special t)
|
||||
(if (or (< pos (match-beginning 1))
|
||||
(= pos (match-end 0)))
|
||||
(goto-char (match-beginning 1))
|
||||
(goto-char (match-end 0)))
|
||||
(if (or (< pos (match-end 0)) (not (eq this-command last-command)))
|
||||
(goto-char (match-end 0))
|
||||
(goto-char (match-beginning 1))))
|
||||
(call-interactively (if (fboundp 'move-end-of-line)
|
||||
'move-end-of-line
|
||||
'end-of-line)))))
|
||||
(org-no-warnings
|
||||
(and (featurep 'xemacs) (setq zmacs-region-stays t)))))
|
||||
|
||||
(define-key org-mode-map "\C-a" 'org-beginning-of-line)
|
||||
(define-key org-mode-map "\C-e" 'org-end-of-line)
|
||||
|
|
Loading…
Reference in New Issue