aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-12-22 22:56:36 +0000
committerStefan Monnier2000-12-22 22:56:36 +0000
commitd21584d6d7dbf850a3da912be52ddda1f92e501a (patch)
treec88ba44290fa9b4772b9d8c08634155bcf4ed8c0
parent26736ce36eb0861020f21ca52f78e49562794894 (diff)
downloademacs-d21584d6d7dbf850a3da912be52ddda1f92e501a.tar.gz
emacs-d21584d6d7dbf850a3da912be52ddda1f92e501a.zip
(skeleton-internal-1): Really make sure the first line of
the region is also re-indented. (skeleton-end-newline): New var. (skeleton-end-hook): Use it.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/skeleton.el39
2 files changed, 25 insertions, 16 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f294d1ff27f..dfb64e4f158 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -2,6 +2,8 @@
2 2
3 * skeleton.el (skeleton-internal-1): Make sure the first line of 3 * skeleton.el (skeleton-internal-1): Make sure the first line of
4 the region is also re-indented. 4 the region is also re-indented.
5 (skeleton-end-newline): New var.
6 (skeleton-end-hook): Use it.
5 7
62000-12-22 Markus Rost <markus.rost@mathematik.uni-regensburg.de> 82000-12-22 Markus Rost <markus.rost@mathematik.uni-regensburg.de>
7 9
diff --git a/lisp/skeleton.el b/lisp/skeleton.el
index 7e29eb6a322..9274c3ca8c9 100644
--- a/lisp/skeleton.el
+++ b/lisp/skeleton.el
@@ -60,11 +60,16 @@ We will probably delete this variable in a future Emacs version
60unless we get a substantial number of complaints about the auto-wrap 60unless we get a substantial number of complaints about the auto-wrap
61feature.") 61feature.")
62 62
63(defvar skeleton-end-newline t
64 "If non-nil, make sure that the skeleton inserted ends with a newline.
65This just influences the way the default `skeleton-end-hook' behaves.")
66
63(defvar skeleton-end-hook 67(defvar skeleton-end-hook
64 (lambda () 68 (lambda ()
65 (or (eolp) (newline-and-indent))) 69 (or (eolp) (not skeleton-end-newline) (newline-and-indent)))
66 "Hook called at end of skeleton but before going to point of interest. 70 "Hook called at end of skeleton but before going to point of interest.
67By default this moves out anything following to next line. 71By default this moves out anything following to next line,
72 unless `skeleton-end-newline' is set to nil.
68The variables `v1' and `v2' are still set when calling this.") 73The variables `v1' and `v2' are still set when calling this.")
69 74
70 75
@@ -375,6 +380,9 @@ automatically, and you are prompted to fill in the variable parts.")))
375 opoint) 380 opoint)
376 (or str 381 (or str
377 (setq str `(setq str (skeleton-read ',(car skeleton) nil ,recursive)))) 382 (setq str `(setq str (skeleton-read ',(car skeleton) nil ,recursive))))
383 (when (and (eq (car skeleton) '\n)
384 (save-excursion (beginning-of-line) (looking-at "[ \t]*$")))
385 (setq skeleton (cons '> (cdr skeleton))))
378 (while (setq skeleton-modified (eq opoint (point)) 386 (while (setq skeleton-modified (eq opoint (point))
379 opoint (point) 387 opoint (point)
380 skeleton (cdr skeleton)) 388 skeleton (cdr skeleton))
@@ -412,20 +420,17 @@ automatically, and you are prompted to fill in the variable parts.")))
412 (funcall skeleton-transformation element) 420 (funcall skeleton-transformation element)
413 element)))) 421 element))))
414 ((eq element '\n) ; actually (eq '\n 'n) 422 ((eq element '\n) ; actually (eq '\n 'n)
415 (if (and skeleton-regions 423 (cond
416 (eq (nth 1 skeleton) '_)) 424 ((and skeleton-regions (eq (nth 1 skeleton) '_))
417 (progn 425 (or (eolp) (newline))
418 (or (eolp) 426 (indent-region (line-beginning-position)
419 (newline)) 427 (car skeleton-regions) nil))
420 (indent-region (point) (car skeleton-regions) nil)) 428 ((and (null (cdr skeleton)) (eolp)) nil)
421 (if skeleton-newline-indent-rigidly 429 (skeleton-newline-indent-rigidly
422 (indent-to (prog1 (current-indentation) 430 (indent-to (prog1 (current-indentation) (newline))))
423 (newline))) 431 (t (newline) (indent-according-to-mode))))
424 (newline)
425 (indent-according-to-mode))))
426 ((eq element '>) 432 ((eq element '>)
427 (if (and skeleton-regions 433 (if (and skeleton-regions (eq (nth 1 skeleton) '_))
428 (eq (nth 1 skeleton) '_))
429 (indent-region (line-beginning-position) 434 (indent-region (line-beginning-position)
430 (car skeleton-regions) nil) 435 (car skeleton-regions) nil)
431 (indent-according-to-mode))) 436 (indent-according-to-mode)))
@@ -446,7 +451,9 @@ automatically, and you are prompted to fill in the variable parts.")))
446 (or skeleton-modified 451 (or skeleton-modified
447 (setq skeleton (cdr skeleton)))) 452 (setq skeleton (cdr skeleton))))
448 ((eq element '@) 453 ((eq element '@)
449 (setq skeleton-positions (cons (point) skeleton-positions))) 454 (if skeleton-point
455 (push (point) skeleton-positions)
456 (setq skeleton-point (point))))
450 ((eq 'quote (car-safe element)) 457 ((eq 'quote (car-safe element))
451 (eval (nth 1 element))) 458 (eval (nth 1 element)))
452 ((or (stringp (car-safe element)) 459 ((or (stringp (car-safe element))