Mercurial > hg > xemacs-beta
comparison lisp/prim/indent.el @ 72:b9518feda344 r20-0b31
Import from CVS: tag r20-0b31
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:03:46 +0200 |
parents | 131b0175ea99 |
children | 3bb7ccffb0c0 |
comparison
equal
deleted
inserted
replaced
71:bae944334fa4 | 72:b9518feda344 |
---|---|
1 ;;; indent.el --- indentation commands for XEmacs | 1 ;;; indent.el --- indentation commands for XEmacs |
2 | |
3 ;; Copyright (C) 1985, 1992, 1993, 1995 Free Software Foundation, Inc. | |
4 | |
5 ;; Maintainer: FSF | |
2 ;; Keywords: lisp languages tools | 6 ;; Keywords: lisp languages tools |
3 | |
4 ;; Copyright (C) 1985, 1992, 1993, 1995 Free Software Foundation, Inc. | |
5 | |
6 ;; Maintainer: FSF | |
7 | 7 |
8 ;; This file is part of XEmacs. | 8 ;; This file is part of XEmacs. |
9 | 9 |
10 ;; XEmacs is free software; you can redistribute it and/or modify it | 10 ;; XEmacs is free software; you can redistribute it and/or modify it |
11 ;; under the terms of the GNU General Public License as published by | 11 ;; under the terms of the GNU General Public License as published by |
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | 16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 ;; General Public License for more details. | 18 ;; General Public License for more details. |
19 | 19 |
20 ;; You should have received a copy of the GNU General Public License | 20 ;; You should have received a copy of the GNU General Public License |
21 ;; along with XEmacs; see the file COPYING. If not, write to the | 21 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
22 ;; Free Software Foundation, 59 Temple Place - Suite 330, | 22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
23 ;; Boston, MA 02111-1307, USA. | 23 ;; 02111-1307, USA. |
24 | 24 |
25 ;;; Synched up with: FSF 19.30. | 25 ;;; Synched up with: FSF 19.30. |
26 | 26 |
27 ;;; Commentary: | 27 ;;; Commentary: |
28 | 28 |
44 | 44 |
45 (defun indent-for-tab-command (&optional prefix-arg) | 45 (defun indent-for-tab-command (&optional prefix-arg) |
46 "Indent line in proper way for current major mode." | 46 "Indent line in proper way for current major mode." |
47 (interactive "P") | 47 (interactive "P") |
48 (if (eq indent-line-function 'indent-to-left-margin) | 48 (if (eq indent-line-function 'indent-to-left-margin) |
49 (insert-tab) | 49 (insert-tab prefix-arg) |
50 (if prefix-arg | 50 (if prefix-arg |
51 (funcall indent-line-function prefix-arg) | 51 (funcall indent-line-function prefix-arg) |
52 (funcall indent-line-function)))) | 52 (funcall indent-line-function)))) |
53 | 53 |
54 (defun insert-tab () | 54 (defun insert-tab (&optional prefix-arg) |
55 (if abbrev-mode | 55 (let ((count (prefix-numeric-value prefix-arg))) |
56 (expand-abbrev)) | 56 (if abbrev-mode |
57 (if indent-tabs-mode | 57 (expand-abbrev)) |
58 (insert ?\t) | 58 (if indent-tabs-mode |
59 (indent-to (* tab-width (1+ (/ (current-column) tab-width)))))) | 59 (insert-char ?\t count) |
60 ;; XEmacs: (Need the `1+') | |
61 (indent-to (* tab-width (1+ (/ (current-column) tab-width))))))) | |
60 | 62 |
61 (defun indent-rigidly (start end arg) | 63 (defun indent-rigidly (start end arg) |
62 "Indent all lines starting in the region sideways by ARG columns. | 64 "Indent all lines starting in the region sideways by ARG columns. |
63 Called from a program, takes three arguments, START, END and ARG." | 65 Called from a program, takes three arguments, START, END and ARG." |
64 (interactive "r\np") | 66 (interactive "r\np") |
76 (or eol-flag | 78 (or eol-flag |
77 (indent-to (max 0 (+ indent arg)) 0)) | 79 (indent-to (max 0 (+ indent arg)) 0)) |
78 (delete-region (point) (progn (skip-chars-forward " \t") (point)))) | 80 (delete-region (point) (progn (skip-chars-forward " \t") (point)))) |
79 (forward-line 1)) | 81 (forward-line 1)) |
80 (move-marker end nil) | 82 (move-marker end nil) |
81 (setq zmacs-region-stays nil))) | 83 (setq zmacs-region-stays nil))) ; XEmacs |
82 | 84 |
83 (defun indent-line-to (column) | 85 (defun indent-line-to (column) |
84 "Indent current line to COLUMN. | 86 "Indent current line to COLUMN. |
85 This function removes or adds spaces and tabs at beginning of line | 87 This function removes or adds spaces and tabs at beginning of line |
86 only if necessary. It leaves point at end of indentation." | 88 only if necessary. It leaves point at end of indentation." |
205 (goto-char from) | 207 (goto-char from) |
206 (skip-chars-backward " \t") | 208 (skip-chars-backward " \t") |
207 (if (bolp) (setq from (point))) | 209 (if (bolp) (setq from (point))) |
208 (goto-char to) | 210 (goto-char to) |
209 (setq to (point-marker))) | 211 (setq to (point-marker))) |
210 (alter-text-property from (marker-position to) 'left-margin | 212 (alter-text-property from (marker-position to) 'left-margin ; XEmacs |
211 (lambda (v) (max (- left-margin) (+ inc (or v 0))))) | 213 (lambda (v) (max (- left-margin) (+ inc (or v 0))))) |
212 (indent-rigidly from (marker-position to) inc) | 214 (indent-rigidly from (marker-position to) inc) ; XEmacs |
213 (if auto-fill-function | 215 (if auto-fill-function |
214 (save-excursion | 216 (save-excursion |
215 (fill-region from (marker-position to) nil t t))) | 217 (fill-region from (marker-position to) nil t t))) ; XEmacs |
216 (move-marker to nil)) | 218 (move-marker to nil)) |
217 | 219 |
218 (defun decrease-left-margin (from to inc) | 220 (defun decrease-left-margin (from to inc) |
219 "Make the left margin of the region smaller. | 221 "Make the left margin of the region smaller. |
220 With no prefix argument, decrease the indentation by `standard-indent'. | 222 With no prefix argument, decrease the indentation by `standard-indent'. |
268 (not (string-equal fill-prefix ""))) | 270 (not (string-equal fill-prefix ""))) |
269 (if (equal fill-prefix | 271 (if (equal fill-prefix |
270 (buffer-substring | 272 (buffer-substring |
271 (point) (min (point-max) (+ (length fill-prefix) (point))))) | 273 (point) (min (point-max) (+ (length fill-prefix) (point))))) |
272 (forward-char (length fill-prefix))) | 274 (forward-char (length fill-prefix))) |
273 (if (and adaptive-fill-mode | 275 (if (and adaptive-fill-mode adaptive-fill-regexp |
274 (looking-at adaptive-fill-regexp)) | 276 (looking-at adaptive-fill-regexp)) |
275 (goto-char (match-end 0)))) | 277 (goto-char (match-end 0)))) |
276 ;; Skip centering or flushright indentation | 278 ;; Skip centering or flushright indentation |
277 (if (memq (current-justification) '(center right)) | 279 (if (memq (current-justification) '(center right)) |
278 (skip-chars-forward " \t"))) | 280 (skip-chars-forward " \t"))) |
332 (indent-relative t)) | 334 (indent-relative t)) |
333 | 335 |
334 (defun indent-relative (&optional unindented-ok) | 336 (defun indent-relative (&optional unindented-ok) |
335 "Space out to under next indent point in previous nonblank line. | 337 "Space out to under next indent point in previous nonblank line. |
336 An indent point is a non-whitespace character following whitespace. | 338 An indent point is a non-whitespace character following whitespace. |
337 If the previous nonblank line has no indent points beyond | 339 If the previous nonblank line has no indent points beyond the |
338 the column point starts at, `tab-to-tab-stop' is done instead." | 340 column point starts at, `tab-to-tab-stop' is done instead." |
339 (interactive "P") | 341 (interactive "P") |
340 (if abbrev-mode (expand-abbrev)) | 342 (if abbrev-mode (expand-abbrev)) |
341 (let ((start-column (current-column)) | 343 (let ((start-column (current-column)) |
342 indent) | 344 indent) |
343 (save-excursion | 345 (save-excursion |
406 (setq count (1+ count))) | 408 (setq count (1+ count))) |
407 (insert ?\n) | 409 (insert ?\n) |
408 (while (> count 0) | 410 (while (> count 0) |
409 (insert "0123456789") | 411 (insert "0123456789") |
410 (setq count (1- count)))) | 412 (setq count (1- count)))) |
413 ;; XEmacs | |
411 (insert (substitute-command-keys "\nTo install changes, type \\<edit-tab-stops-map>\\[edit-tab-stops-note-changes]")) | 414 (insert (substitute-command-keys "\nTo install changes, type \\<edit-tab-stops-map>\\[edit-tab-stops-note-changes]")) |
412 (goto-char (point-min))) | 415 (goto-char (point-min))) |
413 | 416 |
414 (defun edit-tab-stops-note-changes () | 417 (defun edit-tab-stops-note-changes () |
415 "Put edited tab stops into effect." | 418 "Put edited tab stops into effect." |
463 (while (and (> (current-column) tabend) | 466 (while (and (> (current-column) tabend) |
464 (eq (preceding-char) ?\ )) | 467 (eq (preceding-char) ?\ )) |
465 (forward-char -1)) | 468 (forward-char -1)) |
466 (delete-region (point) before)))))))) | 469 (delete-region (point) before)))))))) |
467 | 470 |
471 ;(define-key global-map "\t" 'indent-for-tab-command) | |
472 ;(define-key esc-map "\034" 'indent-region) | |
473 ;(define-key ctl-x-map "\t" 'indent-rigidly) | |
474 ;(define-key esc-map "i" 'tab-to-tab-stop) | |
475 | |
468 ;;; indent.el ends here | 476 ;;; indent.el ends here |