[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a simple convenience function
From: |
Paul Pogonyshev |
Subject: |
a simple convenience function |
Date: |
Sun, 14 Nov 2004 23:36:00 +0200 |
User-agent: |
KMail/1.4.3 |
I'm not sure this issue wasn't raised already, but what do
you think about adding this simple function to Emasc? It
could just sit there for optional binding through `~/.emacs'
by those who like this behaviour. Or we could make behaviour
of the Home key customizeable.
Quick explanation: in the line
some t[>>point<<]ext here
after first evaluation of proposed function we get
[>>point<<]some text here
and after second evaluation we get
[>>point<<] some text here
Paul
--- indent.el 24 Oct 2004 23:58:43 +0300 1.59
+++ indent.el 14 Nov 2004 23:28:35 +0200
@@ -329,6 +329,21 @@ line, but does not move past any whitesp
(if (memq (current-justification) '(center right))
(skip-chars-forward " \t")))
+(defun beginning-of-line-smart (&optional n)
+ "Move to the beginning of the text on this line, or to the beginning of the
line.
+More exactly, if the point is already at the beginning of the
+line's text (as defined by `beginning-of-line-text'), it is
+placed at the very beginning of the line. Otherwise it is moved
+to the text beginning.
+
+With optional argument, different from 1, behave identically to
+`beginning-of-line-text'."
+ (interactive "p")
+ (let ((current-point (point)))
+ (beginning-of-line-text n)
+ (when (= (point) current-point)
+ (beginning-of-line))))
+
(defvar indent-region-function nil
"Short cut function to indent region using `indent-according-to-mode'.
A value of nil means really run `indent-according-to-mode' on each line.")