Mercurial > emacs
annotate lisp/emacs-lisp/lisp-mode.el @ 106433:7c2192f52cb6
Fix a comment and delete trailing whitespace.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 05 Dec 2009 20:09:49 +0000 |
parents | d1bb0f3aad35 |
children | 806e9f7990d8 |
rev | line source |
---|---|
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
2 |
102263
38cb917d6f8f
(eval-last-sexp): Mention truncation in doc.
Glenn Morris <rgm@gnu.org>
parents:
101201
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
38cb917d6f8f
(eval-last-sexp): Mention truncation in doc.
Glenn Morris <rgm@gnu.org>
parents:
101201
diff
changeset
|
4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
5 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
6 ;; Maintainer: FSF |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
7 ;; Keywords: lisp, languages |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
8 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
10 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
14 ;; (at your option) any later version. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
15 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
19 ;; GNU General Public License for more details. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
20 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
23 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
24 ;;; Commentary: |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
25 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
26 ;; The base major mode for editing Lisp code (used also for Emacs Lisp). |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
27 ;; This mode is documented in the Emacs manual. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
28 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
29 ;;; Code: |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
30 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
31 (defvar font-lock-comment-face) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
32 (defvar font-lock-doc-face) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
33 (defvar font-lock-keywords-case-fold-search) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
34 (defvar font-lock-string-face) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
35 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
36 (defvar lisp-mode-abbrev-table nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
37 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
38 (define-abbrev-table 'lisp-mode-abbrev-table ()) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
39 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
40 (defvar emacs-lisp-mode-syntax-table |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
41 (let ((table (make-syntax-table))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
42 (let ((i 0)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
43 (while (< i ?0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
44 (modify-syntax-entry i "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
45 (setq i (1+ i))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
46 (setq i (1+ ?9)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
47 (while (< i ?A) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
48 (modify-syntax-entry i "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
49 (setq i (1+ i))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
50 (setq i (1+ ?Z)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
51 (while (< i ?a) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
52 (modify-syntax-entry i "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
53 (setq i (1+ i))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
54 (setq i (1+ ?z)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
55 (while (< i 128) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
56 (modify-syntax-entry i "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
57 (setq i (1+ i))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
58 (modify-syntax-entry ?\s " " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
59 ;; Non-break space acts as whitespace. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
60 (modify-syntax-entry ?\x8a0 " " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
61 (modify-syntax-entry ?\t " " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
62 (modify-syntax-entry ?\f " " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
63 (modify-syntax-entry ?\n "> " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
64 ;; This is probably obsolete since nowadays such features use overlays. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
65 ;; ;; Give CR the same syntax as newline, for selective-display. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
66 ;; (modify-syntax-entry ?\^m "> " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
67 (modify-syntax-entry ?\; "< " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
68 (modify-syntax-entry ?` "' " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
69 (modify-syntax-entry ?' "' " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
70 (modify-syntax-entry ?, "' " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
71 (modify-syntax-entry ?@ "' " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
72 ;; Used to be singlequote; changed for flonums. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
73 (modify-syntax-entry ?. "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
74 (modify-syntax-entry ?# "' " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
75 (modify-syntax-entry ?\" "\" " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
76 (modify-syntax-entry ?\\ "\\ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
77 (modify-syntax-entry ?\( "() " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
78 (modify-syntax-entry ?\) ")( " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
79 (modify-syntax-entry ?\[ "(] " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
80 (modify-syntax-entry ?\] ")[ " table)) |
105055
ffba73e9bedc
(emacs-lisp-mode-syntax-table): Give it a doc-string.
Glenn Morris <rgm@gnu.org>
parents:
104975
diff
changeset
|
81 table) |
ffba73e9bedc
(emacs-lisp-mode-syntax-table): Give it a doc-string.
Glenn Morris <rgm@gnu.org>
parents:
104975
diff
changeset
|
82 "Syntax table used in `emacs-lisp-mode'.") |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
83 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
84 (defvar lisp-mode-syntax-table |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
85 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
86 (modify-syntax-entry ?\[ "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
87 (modify-syntax-entry ?\] "_ " table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
88 (modify-syntax-entry ?# "' 14b" table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
89 (modify-syntax-entry ?| "\" 23bn" table) |
105056
ce6271fc65ad
(lisp-mode-syntax-table): Give it a doc-string.
Glenn Morris <rgm@gnu.org>
parents:
105055
diff
changeset
|
90 table) |
ce6271fc65ad
(lisp-mode-syntax-table): Give it a doc-string.
Glenn Morris <rgm@gnu.org>
parents:
105055
diff
changeset
|
91 "Syntax table used in `lisp-mode'.") |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
92 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
93 (defvar lisp-imenu-generic-expression |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
94 (list |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
95 (list nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
96 (purecopy (concat "^\\s-*(" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
97 (eval-when-compile |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
98 (regexp-opt |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
99 '("defun" "defun*" "defsubst" "defmacro" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
100 "defadvice" "define-skeleton" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
101 "define-minor-mode" "define-global-minor-mode" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
102 "define-globalized-minor-mode" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
103 "define-derived-mode" "define-generic-mode" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
104 "define-compiler-macro" "define-modify-macro" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
105 "defsetf" "define-setf-expander" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
106 "define-method-combination" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
107 "defgeneric" "defmethod") t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
108 "\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
109 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
110 (list (purecopy "Variables") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
111 (purecopy (concat "^\\s-*(" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
112 (eval-when-compile |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
113 (regexp-opt |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
114 '("defvar" "defconst" "defconstant" "defcustom" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
115 "defparameter" "define-symbol-macro") t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
116 "\\s-+\\(\\(\\sw\\|\\s_\\)+\\)")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
117 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
118 (list (purecopy "Types") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
119 (purecopy (concat "^\\s-*(" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
120 (eval-when-compile |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
121 (regexp-opt |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
122 '("defgroup" "deftheme" "deftype" "defstruct" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
123 "defclass" "define-condition" "define-widget" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
124 "defface" "defpackage") t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
125 "\\s-+'?\\(\\(\\sw\\|\\s_\\)+\\)")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
126 2)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
127 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
128 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
129 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
130 ;; This was originally in autoload.el and is still used there. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
131 (put 'autoload 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
132 (put 'defun 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
133 (put 'defun* 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
134 (put 'defvar 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
135 (put 'defcustom 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
136 (put 'deftheme 'doc-string-elt 2) |
102998
3193dcef2e7b
* emacs-lisp/lisp-mode.el: Give `deftype' a doc-string-elt
Chong Yidong <cyd@stupidchicken.com>
parents:
102263
diff
changeset
|
137 (put 'deftype 'doc-string-elt 3) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
138 (put 'defconst 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
139 (put 'defmacro 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
140 (put 'defmacro* 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
141 (put 'defsubst 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
142 (put 'defstruct 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
143 (put 'define-skeleton 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
144 (put 'define-derived-mode 'doc-string-elt 4) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
145 (put 'define-compilation-mode 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
146 (put 'easy-mmode-define-minor-mode 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
147 (put 'define-minor-mode 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
148 (put 'easy-mmode-define-global-mode 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
149 (put 'define-global-minor-mode 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
150 (put 'define-globalized-minor-mode 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
151 (put 'define-generic-mode 'doc-string-elt 7) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
152 (put 'define-ibuffer-filter 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
153 (put 'define-ibuffer-op 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
154 (put 'define-ibuffer-sorter 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
155 (put 'lambda 'doc-string-elt 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
156 (put 'defalias 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
157 (put 'defvaralias 'doc-string-elt 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
158 (put 'define-category 'doc-string-elt 2) |
105235
f2e56d1eff32
* menu-bar.el: Remove menu-bar-ediff-misc-menu from the Tools
Chong Yidong <cyd@stupidchicken.com>
parents:
105056
diff
changeset
|
159 (put 'define-overloadable-function 'doc-string-elt 3) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
160 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
161 (defvar lisp-doc-string-elt-property 'doc-string-elt |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
162 "The symbol property that holds the docstring position info.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
163 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
164 (defun lisp-font-lock-syntactic-face-function (state) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
165 (if (nth 3 state) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
166 ;; This might be a (doc)string or a |...| symbol. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
167 (let ((startpos (nth 8 state))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
168 (if (eq (char-after startpos) ?|) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
169 ;; This is not a string, but a |...| symbol. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
170 nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
171 (let* ((listbeg (nth 1 state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
172 (firstsym (and listbeg |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
173 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
174 (goto-char listbeg) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
175 (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
176 (match-string 1))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
177 (docelt (and firstsym (get (intern-soft firstsym) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
178 lisp-doc-string-elt-property)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
179 (if (and docelt |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
180 ;; It's a string in a form that can have a docstring. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
181 ;; Check whether it's in docstring position. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
182 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
183 (when (functionp docelt) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
184 (goto-char (match-end 1)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
185 (setq docelt (funcall docelt))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
186 (goto-char listbeg) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
187 (forward-char 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
188 (condition-case nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
189 (while (and (> docelt 0) (< (point) startpos) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
190 (progn (forward-sexp 1) t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
191 (setq docelt (1- docelt))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
192 (error nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
193 (and (zerop docelt) (<= (point) startpos) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
194 (progn (forward-comment (point-max)) t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
195 (= (point) (nth 8 state))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
196 font-lock-doc-face |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
197 font-lock-string-face)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
198 font-lock-comment-face)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
199 |
99432
9241443c239d
(lisp-mode-variables): Add new argument
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99371
diff
changeset
|
200 (defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive) |
9241443c239d
(lisp-mode-variables): Add new argument
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99371
diff
changeset
|
201 "Common initialization routine for lisp modes. |
9241443c239d
(lisp-mode-variables): Add new argument
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99371
diff
changeset
|
202 The LISP-SYNTAX argument is used by code in inf-lisp.el and is |
103331
35fd76739f2f
(lisp-mode-variables): Fix doc-string.
Martin Rudalics <rudalics@gmx.at>
parents:
102998
diff
changeset
|
203 \(uselessly) passed from pp.el, chistory.el, gnus-kill.el and |
35fd76739f2f
(lisp-mode-variables): Fix doc-string.
Martin Rudalics <rudalics@gmx.at>
parents:
102998
diff
changeset
|
204 score-mode.el. KEYWORDS-CASE-INSENSITIVE non-nil means that for |
35fd76739f2f
(lisp-mode-variables): Fix doc-string.
Martin Rudalics <rudalics@gmx.at>
parents:
102998
diff
changeset
|
205 font-lock keywords will not be case sensitive." |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
206 (when lisp-syntax |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
207 (set-syntax-table lisp-mode-syntax-table)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
208 (setq local-abbrev-table lisp-mode-abbrev-table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
209 (make-local-variable 'paragraph-ignore-fill-prefix) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
210 (setq paragraph-ignore-fill-prefix t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
211 (make-local-variable 'fill-paragraph-function) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
212 (setq fill-paragraph-function 'lisp-fill-paragraph) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
213 ;; Adaptive fill mode gets the fill wrong for a one-line paragraph made of |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
214 ;; a single docstring. Let's fix it here. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
215 (set (make-local-variable 'adaptive-fill-function) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
216 (lambda () (if (looking-at "\\s-+\"[^\n\"]+\"\\s-*$") ""))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
217 ;; Adaptive fill mode gets in the way of auto-fill, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
218 ;; and should make no difference for explicit fill |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
219 ;; because lisp-fill-paragraph should do the job. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
220 ;; I believe that newcomment's auto-fill code properly deals with it -stef |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
221 ;;(set (make-local-variable 'adaptive-fill-mode) nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
222 (make-local-variable 'indent-line-function) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
223 (setq indent-line-function 'lisp-indent-line) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
224 (make-local-variable 'parse-sexp-ignore-comments) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
225 (setq parse-sexp-ignore-comments t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
226 (make-local-variable 'outline-regexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
227 (setq outline-regexp ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|(") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
228 (make-local-variable 'outline-level) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
229 (setq outline-level 'lisp-outline-level) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
230 (make-local-variable 'comment-start) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
231 (setq comment-start ";") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
232 (make-local-variable 'comment-start-skip) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
233 ;; Look within the line for a ; following an even number of backslashes |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
234 ;; after either a non-backslash or the line beginning. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
235 (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
236 (make-local-variable 'font-lock-comment-start-skip) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
237 ;; Font lock mode uses this only when it KNOWS a comment is starting. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
238 (setq font-lock-comment-start-skip ";+ *") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
239 (make-local-variable 'comment-add) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
240 (setq comment-add 1) ;default to `;;' in comment-region |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
241 (make-local-variable 'comment-column) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
242 (setq comment-column 40) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
243 ;; Don't get confused by `;' in doc strings when paragraph-filling. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
244 (set (make-local-variable 'comment-use-global-state) t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
245 (make-local-variable 'imenu-generic-expression) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
246 (setq imenu-generic-expression lisp-imenu-generic-expression) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
247 (make-local-variable 'multibyte-syntax-as-symbol) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
248 (setq multibyte-syntax-as-symbol t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
249 (set (make-local-variable 'syntax-begin-function) 'beginning-of-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
250 (setq font-lock-defaults |
99432
9241443c239d
(lisp-mode-variables): Add new argument
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99371
diff
changeset
|
251 `((lisp-font-lock-keywords |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
252 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) |
99432
9241443c239d
(lisp-mode-variables): Add new argument
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99371
diff
changeset
|
253 nil ,keywords-case-insensitive (("+-*/.<>=!?$%_&~^:@" . "w")) nil |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
254 (font-lock-mark-block-function . mark-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
255 (font-lock-syntactic-face-function |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
256 . lisp-font-lock-syntactic-face-function)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
257 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
258 (defun lisp-outline-level () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
259 "Lisp mode `outline-level' function." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
260 (let ((len (- (match-end 0) (match-beginning 0)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
261 (if (looking-at "(\\|;;;###autoload") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
262 1000 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
263 len))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
264 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
265 (defvar lisp-mode-shared-map |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
266 (let ((map (make-sparse-keymap))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
267 (define-key map "\e\C-q" 'indent-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
268 (define-key map "\177" 'backward-delete-char-untabify) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
269 ;; This gets in the way when viewing a Lisp file in view-mode. As |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
270 ;; long as [backspace] is mapped into DEL via the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
271 ;; function-key-map, this should remain disabled!! |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
272 ;;;(define-key map [backspace] 'backward-delete-char-untabify) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
273 map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
274 "Keymap for commands shared by all sorts of Lisp modes.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
275 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
276 (defvar emacs-lisp-mode-map |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
277 (let ((map (make-sparse-keymap "Emacs-Lisp")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
278 (menu-map (make-sparse-keymap "Emacs-Lisp")) |
104045
1b791c5d1cee
(emacs-lisp-mode-map): Add menu entries
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103512
diff
changeset
|
279 (lint-map (make-sparse-keymap)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
280 (prof-map (make-sparse-keymap)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
281 (tracing-map (make-sparse-keymap))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
282 (set-keymap-parent map lisp-mode-shared-map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
283 (define-key map "\e\t" 'lisp-complete-symbol) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
284 (define-key map "\e\C-x" 'eval-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
285 (define-key map "\e\C-q" 'indent-pp-sexp) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
286 (define-key map [menu-bar emacs-lisp] (cons (purecopy "Emacs-Lisp") menu-map)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
287 (define-key menu-map [eldoc] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
288 `(menu-item ,(purecopy "Auto-Display Documentation Strings") eldoc-mode |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
289 :button (:toggle . (bound-and-true-p eldoc-mode)) |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
290 :help ,(purecopy "Display the documentation string for the item under cursor"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
291 (define-key menu-map [checkdoc] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
292 `(menu-item ,(purecopy "Check Documentation Strings") checkdoc |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
293 :help ,(purecopy "Check documentation strings for style requirements"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
294 (define-key menu-map [re-builder] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
295 `(menu-item ,(purecopy "Construct Regexp") re-builder |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
296 :help ,(purecopy "Construct a regexp interactively"))) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
297 (define-key menu-map [tracing] (cons (purecopy "Tracing") tracing-map)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
298 (define-key tracing-map [tr-a] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
299 `(menu-item ,(purecopy "Untrace all") untrace-all |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
300 :help ,(purecopy "Untrace all currently traced functions"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
301 (define-key tracing-map [tr-uf] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
302 `(menu-item ,(purecopy "Untrace function...") untrace-function |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
303 :help ,(purecopy "Untrace function, and possibly activate all remaining advice"))) |
105941
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
304 (define-key tracing-map [tr-sep] menu-bar-separator) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
305 (define-key tracing-map [tr-q] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
306 `(menu-item ,(purecopy "Trace function quietly...") trace-function-background |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
307 :help ,(purecopy "Trace the function with trace output going quietly to a buffer"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
308 (define-key tracing-map [tr-f] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
309 `(menu-item ,(purecopy "Trace function...") trace-function |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
310 :help ,(purecopy "Trace the function given as an argument"))) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
311 (define-key menu-map [profiling] (cons (purecopy "Profiling") prof-map)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
312 (define-key prof-map [prof-restall] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
313 `(menu-item ,(purecopy "Remove Instrumentation for All Functions") elp-restore-all |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
314 :help ,(purecopy "Restore the original definitions of all functions being profiled"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
315 (define-key prof-map [prof-restfunc] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
316 `(menu-item ,(purecopy "Remove Instrumentation for Function...") elp-restore-function |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
317 :help ,(purecopy "Restore an instrumented function to its original definition"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
318 |
105941
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
319 (define-key prof-map [sep-rem] menu-bar-separator) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
320 (define-key prof-map [prof-resall] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
321 `(menu-item ,(purecopy "Reset Counters for All Functions") elp-reset-all |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
322 :help ,(purecopy "Reset the profiling information for all functions being profiled"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
323 (define-key prof-map [prof-resfunc] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
324 `(menu-item ,(purecopy "Reset Counters for Function...") elp-reset-function |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
325 :help ,(purecopy "Reset the profiling information for a function"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
326 (define-key prof-map [prof-res] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
327 `(menu-item ,(purecopy "Show Profiling Results") elp-results |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
328 :help ,(purecopy "Display current profiling results"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
329 (define-key prof-map [prof-pack] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
330 `(menu-item ,(purecopy "Instrument Package...") elp-instrument-package |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
331 :help ,(purecopy "Instrument for profiling all function that start with a prefix"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
332 (define-key prof-map [prof-func] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
333 `(menu-item ,(purecopy "Instrument Function...") elp-instrument-function |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
334 :help ,(purecopy "Instrument a function for profiling"))) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
335 (define-key menu-map [lint] (cons (purecopy "Linting") lint-map)) |
104975
b866a533c9f3
(emacs-lisp-mode-map): Add menu entries to elint file and directory.
Glenn Morris <rgm@gnu.org>
parents:
104303
diff
changeset
|
336 (define-key lint-map [lint-di] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
337 `(menu-item ,(purecopy "Lint Directory...") elint-directory |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
338 :help ,(purecopy "Lint a directory"))) |
104975
b866a533c9f3
(emacs-lisp-mode-map): Add menu entries to elint file and directory.
Glenn Morris <rgm@gnu.org>
parents:
104303
diff
changeset
|
339 (define-key lint-map [lint-f] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
340 `(menu-item ,(purecopy "Lint File...") elint-file |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
341 :help ,(purecopy "Lint a file"))) |
104045
1b791c5d1cee
(emacs-lisp-mode-map): Add menu entries
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103512
diff
changeset
|
342 (define-key lint-map [lint-b] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
343 `(menu-item ,(purecopy "Lint Buffer") elint-current-buffer |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
344 :help ,(purecopy "Lint the current buffer"))) |
104045
1b791c5d1cee
(emacs-lisp-mode-map): Add menu entries
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103512
diff
changeset
|
345 (define-key lint-map [lint-d] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
346 `(menu-item ,(purecopy "Lint Defun") elint-defun |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
347 :help ,(purecopy "Lint the function at point"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
348 (define-key menu-map [edebug-defun] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
349 `(menu-item ,(purecopy "Instrument Function for Debugging") edebug-defun |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
350 :help ,(purecopy "Evaluate the top level form point is in, stepping through with Edebug") |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105765
diff
changeset
|
351 :keys ,(purecopy "C-u C-M-x"))) |
105941
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
352 (define-key menu-map [separator-byte] menu-bar-separator) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
353 (define-key menu-map [disas] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
354 `(menu-item ,(purecopy "Disassemble byte compiled object...") disassemble |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
355 :help ,(purecopy "Print disassembled code for OBJECT in a buffer"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
356 (define-key menu-map [byte-recompile] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
357 `(menu-item ,(purecopy "Byte-recompile Directory...") byte-recompile-directory |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
358 :help ,(purecopy "Recompile every `.el' file in DIRECTORY that needs recompilation"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
359 (define-key menu-map [emacs-byte-compile-and-load] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
360 `(menu-item ,(purecopy "Byte-compile And Load") emacs-lisp-byte-compile-and-load |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
361 :help ,(purecopy "Byte-compile the current file (if it has changed), then load compiled code"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
362 (define-key menu-map [byte-compile] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
363 `(menu-item ,(purecopy "Byte-compile This File") emacs-lisp-byte-compile |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
364 :help ,(purecopy "Byte compile the file containing the current buffer"))) |
105941
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
365 (define-key menu-map [separator-eval] menu-bar-separator) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
366 (define-key menu-map [ielm] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
367 `(menu-item ,(purecopy "Interactive Expression Evaluation") ielm |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
368 :help ,(purecopy "Interactively evaluate Emacs Lisp expressions"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
369 (define-key menu-map [eval-buffer] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
370 `(menu-item ,(purecopy "Evaluate Buffer") eval-buffer |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
371 :help ,(purecopy "Execute the current buffer as Lisp code"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
372 (define-key menu-map [eval-region] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
373 `(menu-item ,(purecopy "Evaluate Region") eval-region |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
374 :help ,(purecopy "Execute the region as Lisp code") |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
375 :enable mark-active)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
376 (define-key menu-map [eval-sexp] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
377 `(menu-item ,(purecopy "Evaluate Last S-expression") eval-last-sexp |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
378 :help ,(purecopy "Evaluate sexp before point; print value in minibuffer"))) |
105941
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
379 (define-key menu-map [separator-format] menu-bar-separator) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
380 (define-key menu-map [comment-region] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
381 `(menu-item ,(purecopy "Comment Out Region") comment-region |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
382 :help ,(purecopy "Comment or uncomment each line in the region") |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
383 :enable mark-active)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
384 (define-key menu-map [indent-region] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
385 `(menu-item ,(purecopy "Indent Region") indent-region |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
386 :help ,(purecopy "Indent each nonblank line in the region") |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
387 :enable mark-active)) |
105941
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
388 (define-key menu-map [indent-line] |
d1bb0f3aad35
* net/eudc.el (eudc-tools-menu):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105870
diff
changeset
|
389 `(menu-item ,(purecopy "Indent Line") lisp-indent-line)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
390 map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
391 "Keymap for Emacs Lisp mode. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
392 All commands in `lisp-mode-shared-map' are inherited by this map.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
393 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
394 (defun emacs-lisp-byte-compile () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
395 "Byte compile the file containing the current buffer." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
396 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
397 (if buffer-file-name |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
398 (byte-compile-file buffer-file-name) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
399 (error "The buffer must be saved in a file first"))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
400 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
401 (defun emacs-lisp-byte-compile-and-load () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
402 "Byte-compile the current file (if it has changed), then load compiled code." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
403 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
404 (or buffer-file-name |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
405 (error "The buffer must be saved in a file first")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
406 (require 'bytecomp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
407 ;; Recompile if file or buffer has changed since last compilation. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
408 (if (and (buffer-modified-p) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
409 (y-or-n-p (format "Save buffer %s first? " (buffer-name)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
410 (save-buffer)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
411 (let ((compiled-file-name (byte-compile-dest-file buffer-file-name))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
412 (if (file-newer-than-file-p compiled-file-name buffer-file-name) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
413 (load-file compiled-file-name) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
414 (byte-compile-file buffer-file-name t)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
415 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
416 (defcustom emacs-lisp-mode-hook nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
417 "Hook run when entering Emacs Lisp mode." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
418 :options '(turn-on-eldoc-mode imenu-add-menubar-index checkdoc-minor-mode) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
419 :type 'hook |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
420 :group 'lisp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
421 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
422 (defcustom lisp-mode-hook nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
423 "Hook run when entering Lisp mode." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
424 :options '(imenu-add-menubar-index) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
425 :type 'hook |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
426 :group 'lisp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
427 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
428 (defcustom lisp-interaction-mode-hook nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
429 "Hook run when entering Lisp Interaction mode." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
430 :options '(turn-on-eldoc-mode) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
431 :type 'hook |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
432 :group 'lisp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
433 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
434 (defun emacs-lisp-mode () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
435 "Major mode for editing Lisp code to run in Emacs. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
436 Commands: |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
437 Delete converts tabs to spaces as it moves back. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
438 Blank lines separate paragraphs. Semicolons start comments. |
100889
fa6fe6da548a
* emacs-lisp/lisp-mode.el (emacs-lisp-mode, lisp-mode, lisp-interaction-mode):
Juanma Barranquero <lekktu@gmail.com>
parents:
99713
diff
changeset
|
439 |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
440 \\{emacs-lisp-mode-map} |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
441 Entry to this mode calls the value of `emacs-lisp-mode-hook' |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
442 if that value is non-nil." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
443 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
444 (kill-all-local-variables) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
445 (use-local-map emacs-lisp-mode-map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
446 (set-syntax-table emacs-lisp-mode-syntax-table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
447 (setq major-mode 'emacs-lisp-mode) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
448 (setq mode-name "Emacs-Lisp") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
449 (lisp-mode-variables) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
450 (setq imenu-case-fold-search nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
451 (run-mode-hooks 'emacs-lisp-mode-hook)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
452 (put 'emacs-lisp-mode 'custom-mode-group 'lisp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
453 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
454 (defvar lisp-mode-map |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
455 (let ((map (make-sparse-keymap)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
456 (menu-map (make-sparse-keymap "Lisp"))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
457 (set-keymap-parent map lisp-mode-shared-map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
458 (define-key map "\e\C-x" 'lisp-eval-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
459 (define-key map "\C-c\C-z" 'run-lisp) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
460 (define-key map [menu-bar lisp] (cons (purecopy "Lisp") menu-map)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
461 (define-key menu-map [run-lisp] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
462 `(menu-item ,(purecopy "Run inferior Lisp") run-lisp |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
463 :help ,(purecopy "Run an inferior Lisp process, input and output via buffer `*inferior-lisp*'"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
464 (define-key menu-map [ev-def] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
465 `(menu-item ,(purecopy "Eval defun") lisp-eval-defun |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
466 :help ,(purecopy "Send the current defun to the Lisp process made by M-x run-lisp"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
467 (define-key menu-map [ind-sexp] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
468 `(menu-item ,(purecopy "Indent sexp") indent-sexp |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
469 :help ,(purecopy "Indent each line of the list starting just after point"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
470 map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
471 "Keymap for ordinary Lisp mode. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
472 All commands in `lisp-mode-shared-map' are inherited by this map.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
473 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
474 (defun lisp-mode () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
475 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
476 Commands: |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
477 Delete converts tabs to spaces as it moves back. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
478 Blank lines separate paragraphs. Semicolons start comments. |
100889
fa6fe6da548a
* emacs-lisp/lisp-mode.el (emacs-lisp-mode, lisp-mode, lisp-interaction-mode):
Juanma Barranquero <lekktu@gmail.com>
parents:
99713
diff
changeset
|
479 |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
480 \\{lisp-mode-map} |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
481 Note that `run-lisp' may be used either to start an inferior Lisp job |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
482 or to switch back to an existing one. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
483 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
484 Entry to this mode calls the value of `lisp-mode-hook' |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
485 if that value is non-nil." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
486 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
487 (kill-all-local-variables) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
488 (use-local-map lisp-mode-map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
489 (setq major-mode 'lisp-mode) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
490 (setq mode-name "Lisp") |
99432
9241443c239d
(lisp-mode-variables): Add new argument
Dan Nicolaescu <dann@ics.uci.edu>
parents:
99371
diff
changeset
|
491 (lisp-mode-variables nil t) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
492 (make-local-variable 'comment-start-skip) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
493 (setq comment-start-skip |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
494 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
495 (setq imenu-case-fold-search t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
496 (set-syntax-table lisp-mode-syntax-table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
497 (run-mode-hooks 'lisp-mode-hook)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
498 (put 'lisp-mode 'find-tag-default-function 'lisp-find-tag-default) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
499 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
500 (defun lisp-find-tag-default () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
501 (let ((default (find-tag-default))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
502 (when (stringp default) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
503 (if (string-match ":+" default) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
504 (substring default (match-end 0)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
505 default)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
506 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
507 ;; Used in old LispM code. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
508 (defalias 'common-lisp-mode 'lisp-mode) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
509 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
510 ;; This will do unless inf-lisp.el is loaded. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
511 (defun lisp-eval-defun (&optional and-go) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
512 "Send the current defun to the Lisp process made by \\[run-lisp]." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
513 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
514 (error "Process lisp does not exist")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
515 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
516 (defvar lisp-interaction-mode-map |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
517 (let ((map (make-sparse-keymap)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
518 (menu-map (make-sparse-keymap "Lisp-Interaction"))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
519 (set-keymap-parent map lisp-mode-shared-map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
520 (define-key map "\e\C-x" 'eval-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
521 (define-key map "\e\C-q" 'indent-pp-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
522 (define-key map "\e\t" 'lisp-complete-symbol) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
523 (define-key map "\n" 'eval-print-last-sexp) |
105765
db5e4a5897ec
* textmodes/tex-mode.el (tex-dvi-view-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105744
diff
changeset
|
524 (define-key map [menu-bar lisp-interaction] (cons (purecopy "Lisp-Interaction") menu-map)) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
525 (define-key menu-map [eval-defun] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
526 `(menu-item ,(purecopy "Evaluate Defun") eval-defun |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
527 :help ,(purecopy "Evaluate the top-level form containing point, or after point"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
528 (define-key menu-map [eval-print-last-sexp] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
529 `(menu-item ,(purecopy "Evaluate and print") eval-print-last-sexp |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
530 :help ,(purecopy "Evaluate sexp before point; print value into current buffer"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
531 (define-key menu-map [edebug-defun-lisp-interaction] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
532 `(menu-item ,(purecopy "Instrument Function for Debugging") edebug-defun |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
533 :help ,(purecopy "Evaluate the top level form point is in, stepping through with Edebug") |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105765
diff
changeset
|
534 :keys ,(purecopy "C-u C-M-x"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
535 (define-key menu-map [indent-pp-sexp] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
536 `(menu-item ,(purecopy "Indent or Pretty-Print") indent-pp-sexp |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
537 :help ,(purecopy "Indent each line of the list starting just after point, or prettyprint it"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
538 (define-key menu-map [lisp-complete-symbol] |
105744
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
539 `(menu-item ,(purecopy "Complete Lisp Symbol") lisp-complete-symbol |
b0a732611398
* keymap.c (Fmake_sparse_keymap): Purecopy the name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105664
diff
changeset
|
540 :help ,(purecopy "Perform completion on Lisp symbol preceding point"))) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
541 map) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
542 "Keymap for Lisp Interaction mode. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
543 All commands in `lisp-mode-shared-map' are inherited by this map.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
544 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
545 (defvar lisp-interaction-mode-abbrev-table lisp-mode-abbrev-table) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
546 (define-derived-mode lisp-interaction-mode emacs-lisp-mode "Lisp Interaction" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
547 "Major mode for typing and evaluating Lisp forms. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
548 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
549 before point, and prints its value into the buffer, advancing point. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
550 Note that printing is controlled by `eval-expression-print-length' |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
551 and `eval-expression-print-level'. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
552 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
553 Commands: |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
554 Delete converts tabs to spaces as it moves back. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
555 Paragraphs are separated only by blank lines. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
556 Semicolons start comments. |
100889
fa6fe6da548a
* emacs-lisp/lisp-mode.el (emacs-lisp-mode, lisp-mode, lisp-interaction-mode):
Juanma Barranquero <lekktu@gmail.com>
parents:
99713
diff
changeset
|
557 |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
558 \\{lisp-interaction-mode-map} |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
559 Entry to this mode calls the value of `lisp-interaction-mode-hook' |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
560 if that value is non-nil.") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
561 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
562 (defun eval-print-last-sexp () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
563 "Evaluate sexp before point; print value into current buffer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
564 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
565 If `eval-expression-debug-on-error' is non-nil, which is the default, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
566 this command arranges for all errors to enter the debugger. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
567 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
568 Note that printing the result is controlled by the variables |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
569 `eval-expression-print-length' and `eval-expression-print-level', |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
570 which see." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
571 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
572 (let ((standard-output (current-buffer))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
573 (terpri) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
574 (eval-last-sexp t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
575 (terpri))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
576 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
577 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
578 (defun last-sexp-setup-props (beg end value alt1 alt2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
579 "Set up text properties for the output of `eval-last-sexp-1'. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
580 BEG and END are the start and end of the output in current-buffer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
581 VALUE is the Lisp value printed, ALT1 and ALT2 are strings for the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
582 alternative printed representations that can be displayed." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
583 (let ((map (make-sparse-keymap))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
584 (define-key map "\C-m" 'last-sexp-toggle-display) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
585 (define-key map [down-mouse-2] 'mouse-set-point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
586 (define-key map [mouse-2] 'last-sexp-toggle-display) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
587 (add-text-properties |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
588 beg end |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
589 `(printed-value (,value ,alt1 ,alt2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
590 mouse-face highlight |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
591 keymap ,map |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
592 help-echo "RET, mouse-2: toggle abbreviated display" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
593 rear-nonsticky (mouse-face keymap help-echo |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
594 printed-value))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
595 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
596 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
597 (defun last-sexp-toggle-display (&optional arg) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
598 "Toggle between abbreviated and unabbreviated printed representations." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
599 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
600 (save-restriction |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
601 (widen) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
602 (let ((value (get-text-property (point) 'printed-value))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
603 (when value |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
604 (let ((beg (or (previous-single-property-change (min (point-max) (1+ (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
605 'printed-value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
606 (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
607 (end (or (next-single-char-property-change (point) 'printed-value) (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
608 (standard-output (current-buffer)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
609 (point (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
610 (delete-region beg end) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
611 (insert (nth 1 value)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
612 (or (= beg point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
613 (setq point (1- (point)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
614 (last-sexp-setup-props beg (point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
615 (nth 0 value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
616 (nth 2 value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
617 (nth 1 value)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
618 (goto-char (min (point-max) point))))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
619 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
620 (defun prin1-char (char) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
621 "Return a string representing CHAR as a character rather than as an integer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
622 If CHAR is not a character, return nil." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
623 (and (integerp char) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
624 (eventp char) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
625 (let ((c (event-basic-type char)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
626 (mods (event-modifiers char)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
627 string) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
628 ;; Prevent ?A from turning into ?\S-a. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
629 (if (and (memq 'shift mods) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
630 (zerop (logand char ?\S-\^@)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
631 (not (let ((case-fold-search nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
632 (char-equal c (upcase c))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
633 (setq c (upcase c) mods nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
634 ;; What string are we considering using? |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
635 (condition-case nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
636 (setq string |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
637 (concat |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
638 "?" |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
639 (mapconcat |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
640 (lambda (modif) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
641 (cond ((eq modif 'super) "\\s-") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
642 (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
643 mods "") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
644 (cond |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
645 ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
646 ((eq c 127) "\\C-?") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
647 (t |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
648 (string c))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
649 (error nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
650 ;; Verify the string reads a CHAR, not to some other character. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
651 ;; If it doesn't, return nil instead. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
652 (and string |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
653 (= (car (read-from-string string)) char) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
654 string)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
655 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
656 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
657 (defun preceding-sexp () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
658 "Return sexp before the point." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
659 (let ((opoint (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
660 ignore-quotes |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
661 expr) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
662 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
663 (with-syntax-table emacs-lisp-mode-syntax-table |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
664 ;; If this sexp appears to be enclosed in `...' |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
665 ;; then ignore the surrounding quotes. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
666 (setq ignore-quotes |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
667 (or (eq (following-char) ?\') |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
668 (eq (preceding-char) ?\'))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
669 (forward-sexp -1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
670 ;; If we were after `?\e' (or similar case), |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
671 ;; use the whole thing, not just the `e'. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
672 (when (eq (preceding-char) ?\\) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
673 (forward-char -1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
674 (when (eq (preceding-char) ??) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
675 (forward-char -1))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
676 |
105664
6a6fcf3e8e4d
* minibuffer.el (read-file-name): Check for repeat before putting
Chong Yidong <cyd@stupidchicken.com>
parents:
105235
diff
changeset
|
677 ;; Skip over hash table read syntax. |
6a6fcf3e8e4d
* minibuffer.el (read-file-name): Check for repeat before putting
Chong Yidong <cyd@stupidchicken.com>
parents:
105235
diff
changeset
|
678 (and (> (point) (1+ (point-min))) |
6a6fcf3e8e4d
* minibuffer.el (read-file-name): Check for repeat before putting
Chong Yidong <cyd@stupidchicken.com>
parents:
105235
diff
changeset
|
679 (looking-back "#s" (- (point) 2)) |
6a6fcf3e8e4d
* minibuffer.el (read-file-name): Check for repeat before putting
Chong Yidong <cyd@stupidchicken.com>
parents:
105235
diff
changeset
|
680 (forward-char -2)) |
6a6fcf3e8e4d
* minibuffer.el (read-file-name): Check for repeat before putting
Chong Yidong <cyd@stupidchicken.com>
parents:
105235
diff
changeset
|
681 |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
682 ;; Skip over `#N='s. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
683 (when (eq (preceding-char) ?=) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
684 (let (labeled-p) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
685 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
686 (skip-chars-backward "0-9#=") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
687 (setq labeled-p (looking-at "\\(#[0-9]+=\\)+"))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
688 (when labeled-p |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
689 (forward-sexp -1)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
690 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
691 (save-restriction |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
692 ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
693 ;; `variable' so that the value is returned, not the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
694 ;; name |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
695 (if (and ignore-quotes |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
696 (eq (following-char) ?`)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
697 (forward-char)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
698 (narrow-to-region (point-min) opoint) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
699 (setq expr (read (current-buffer))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
700 ;; If it's an (interactive ...) form, it's more |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
701 ;; useful to show how an interactive call would |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
702 ;; use it. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
703 (and (consp expr) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
704 (eq (car expr) 'interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
705 (setq expr |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
706 (list 'call-interactively |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
707 (list 'quote |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
708 (list 'lambda |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
709 '(&rest args) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
710 expr |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
711 'args))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
712 expr))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
713 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
714 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
715 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
716 "Evaluate sexp before point; print value in minibuffer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
717 With argument, print output into current buffer." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
718 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
719 (eval-last-sexp-print-value (eval (preceding-sexp))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
720 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
721 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
722 (defun eval-last-sexp-print-value (value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
723 (let ((unabbreviated (let ((print-length nil) (print-level nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
724 (prin1-to-string value))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
725 (print-length eval-expression-print-length) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
726 (print-level eval-expression-print-level) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
727 (beg (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
728 end) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
729 (prog1 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
730 (prin1 value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
731 (let ((str (eval-expression-print-format value))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
732 (if str (princ str))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
733 (setq end (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
734 (when (and (bufferp standard-output) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
735 (or (not (null print-length)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
736 (not (null print-level))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
737 (not (string= unabbreviated |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
738 (buffer-substring-no-properties beg end)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
739 (last-sexp-setup-props beg end value |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
740 unabbreviated |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
741 (buffer-substring-no-properties beg end)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
742 )))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
743 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
744 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
745 (defvar eval-last-sexp-fake-value (make-symbol "t")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
746 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
747 (defun eval-last-sexp (eval-last-sexp-arg-internal) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
748 "Evaluate sexp before point; print value in minibuffer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
749 Interactively, with prefix argument, print output into current buffer. |
102263
38cb917d6f8f
(eval-last-sexp): Mention truncation in doc.
Glenn Morris <rgm@gnu.org>
parents:
101201
diff
changeset
|
750 Truncates long output according to the value of the variables |
38cb917d6f8f
(eval-last-sexp): Mention truncation in doc.
Glenn Morris <rgm@gnu.org>
parents:
101201
diff
changeset
|
751 `eval-expression-print-length' and `eval-expression-print-level'. |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
752 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
753 If `eval-expression-debug-on-error' is non-nil, which is the default, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
754 this command arranges for all errors to enter the debugger." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
755 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
756 (if (null eval-expression-debug-on-error) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
757 (eval-last-sexp-1 eval-last-sexp-arg-internal) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
758 (let ((value |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
759 (let ((debug-on-error eval-last-sexp-fake-value)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
760 (cons (eval-last-sexp-1 eval-last-sexp-arg-internal) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
761 debug-on-error)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
762 (unless (eq (cdr value) eval-last-sexp-fake-value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
763 (setq debug-on-error (cdr value))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
764 (car value)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
765 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
766 (defun eval-defun-1 (form) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
767 "Treat some expressions specially. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
768 Reset the `defvar' and `defcustom' variables to the initial value. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
769 Reinitialize the face according to the `defface' specification." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
770 ;; The code in edebug-defun should be consistent with this, but not |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
771 ;; the same, since this gets a macroexpended form. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
772 (cond ((not (listp form)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
773 form) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
774 ((and (eq (car form) 'defvar) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
775 (cdr-safe (cdr-safe form)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
776 (boundp (cadr form))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
777 ;; Force variable to be re-set. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
778 `(progn (defvar ,(nth 1 form) nil ,@(nthcdr 3 form)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
779 (setq-default ,(nth 1 form) ,(nth 2 form)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
780 ;; `defcustom' is now macroexpanded to |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
781 ;; `custom-declare-variable' with a quoted value arg. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
782 ((and (eq (car form) 'custom-declare-variable) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
783 (default-boundp (eval (nth 1 form)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
784 ;; Force variable to be bound. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
785 (set-default (eval (nth 1 form)) (eval (nth 1 (nth 2 form)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
786 form) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
787 ;; `defface' is macroexpanded to `custom-declare-face'. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
788 ((eq (car form) 'custom-declare-face) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
789 ;; Reset the face. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
790 (setq face-new-frame-defaults |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
791 (assq-delete-all (eval (nth 1 form)) face-new-frame-defaults)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
792 (put (eval (nth 1 form)) 'face-defface-spec nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
793 ;; Setting `customized-face' to the new spec after calling |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
794 ;; the form, but preserving the old saved spec in `saved-face', |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
795 ;; imitates the situation when the new face spec is set |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
796 ;; temporarily for the current session in the customize |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
797 ;; buffer, thus allowing `face-user-default-spec' to use the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
798 ;; new customized spec instead of the saved spec. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
799 ;; Resetting `saved-face' temporarily to nil is needed to let |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
800 ;; `defface' change the spec, regardless of a saved spec. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
801 (prog1 `(prog1 ,form |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
802 (put ,(nth 1 form) 'saved-face |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
803 ',(get (eval (nth 1 form)) 'saved-face)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
804 (put ,(nth 1 form) 'customized-face |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
805 ,(nth 2 form))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
806 (put (eval (nth 1 form)) 'saved-face nil))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
807 ((eq (car form) 'progn) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
808 (cons 'progn (mapcar 'eval-defun-1 (cdr form)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
809 (t form))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
810 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
811 (defun eval-defun-2 () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
812 "Evaluate defun that point is in or before. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
813 The value is displayed in the minibuffer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
814 If the current defun is actually a call to `defvar', |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
815 then reset the variable using the initial value expression |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
816 even if the variable already has some other value. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
817 \(Normally `defvar' does not change the variable's value |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
818 if it already has a value.\) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
819 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
820 With argument, insert value in current buffer after the defun. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
821 Return the result of evaluation." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
822 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
823 ;; FIXME: the print-length/level bindings should only be applied while |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
824 ;; printing, not while evaluating. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
825 (let ((debug-on-error eval-expression-debug-on-error) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
826 (print-length eval-expression-print-length) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
827 (print-level eval-expression-print-level)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
828 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
829 ;; Arrange for eval-region to "read" the (possibly) altered form. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
830 ;; eval-region handles recording which file defines a function or |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
831 ;; variable. Re-written using `apply' to avoid capturing |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
832 ;; variables like `end'. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
833 (apply |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
834 #'eval-region |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
835 (let ((standard-output t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
836 beg end form) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
837 ;; Read the form from the buffer, and record where it ends. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
838 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
839 (end-of-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
840 (beginning-of-defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
841 (setq beg (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
842 (setq form (read (current-buffer))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
843 (setq end (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
844 ;; Alter the form if necessary. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
845 (setq form (eval-defun-1 (macroexpand form))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
846 (list beg end standard-output |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
847 `(lambda (ignore) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
848 ;; Skipping to the end of the specified region |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
849 ;; will make eval-region return. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
850 (goto-char ,end) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
851 ',form)))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
852 ;; The result of evaluation has been put onto VALUES. So return it. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
853 (car values)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
854 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
855 (defun eval-defun (edebug-it) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
856 "Evaluate the top-level form containing point, or after point. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
857 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
858 If the current defun is actually a call to `defvar' or `defcustom', |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
859 evaluating it this way resets the variable using its initial value |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
860 expression even if the variable already has some other value. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
861 \(Normally `defvar' and `defcustom' do not alter the value if there |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
862 already is one.) In an analogous way, evaluating a `defface' |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
863 overrides any customizations of the face, so that it becomes |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
864 defined exactly as the `defface' expression says. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
865 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
866 If `eval-expression-debug-on-error' is non-nil, which is the default, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
867 this command arranges for all errors to enter the debugger. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
868 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
869 With a prefix argument, instrument the code for Edebug. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
870 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
871 If acting on a `defun' for FUNCTION, and the function was |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
872 instrumented, `Edebug: FUNCTION' is printed in the minibuffer. If not |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
873 instrumented, just FUNCTION is printed. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
874 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
875 If not acting on a `defun', the result of evaluation is displayed in |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
876 the minibuffer. This display is controlled by the variables |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
877 `eval-expression-print-length' and `eval-expression-print-level', |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
878 which see." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
879 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
880 (cond (edebug-it |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
881 (require 'edebug) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
882 (eval-defun (not edebug-all-defs))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
883 (t |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
884 (if (null eval-expression-debug-on-error) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
885 (eval-defun-2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
886 (let ((old-value (make-symbol "t")) new-value value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
887 (let ((debug-on-error old-value)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
888 (setq value (eval-defun-2)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
889 (setq new-value debug-on-error)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
890 (unless (eq old-value new-value) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
891 (setq debug-on-error new-value)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
892 value))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
893 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
894 ;; May still be used by some external Lisp-mode variant. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
895 (define-obsolete-function-alias 'lisp-comment-indent |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
896 'comment-indent-default "22.1") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
897 (define-obsolete-function-alias 'lisp-mode-auto-fill 'do-auto-fill "23.1") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
898 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
899 (defcustom lisp-indent-offset nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
900 "If non-nil, indent second line of expressions that many more columns." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
901 :group 'lisp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
902 :type '(choice (const nil) integer)) |
103512
ce2fc4a55d15
(lisp-indent-offset): Fix safe-local-variable property.
Glenn Morris <rgm@gnu.org>
parents:
103499
diff
changeset
|
903 (put 'lisp-indent-offset 'safe-local-variable |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
904 (lambda (x) (or (null x) (integerp x)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
905 |
103512
ce2fc4a55d15
(lisp-indent-offset): Fix safe-local-variable property.
Glenn Morris <rgm@gnu.org>
parents:
103499
diff
changeset
|
906 (defcustom lisp-indent-function 'lisp-indent-function |
103499
247269056555
(lisp-indent-function): Add doc string.
Glenn Morris <rgm@gnu.org>
parents:
103331
diff
changeset
|
907 "A function to be called by `calculate-lisp-indent'. |
247269056555
(lisp-indent-function): Add doc string.
Glenn Morris <rgm@gnu.org>
parents:
103331
diff
changeset
|
908 It indents the arguments of a Lisp function call. This function |
247269056555
(lisp-indent-function): Add doc string.
Glenn Morris <rgm@gnu.org>
parents:
103331
diff
changeset
|
909 should accept two arguments: the indent-point, and the |
247269056555
(lisp-indent-function): Add doc string.
Glenn Morris <rgm@gnu.org>
parents:
103331
diff
changeset
|
910 `parse-partial-sexp' state at that position. One option for this |
103512
ce2fc4a55d15
(lisp-indent-offset): Fix safe-local-variable property.
Glenn Morris <rgm@gnu.org>
parents:
103499
diff
changeset
|
911 function is `common-lisp-indent-function'." |
ce2fc4a55d15
(lisp-indent-offset): Fix safe-local-variable property.
Glenn Morris <rgm@gnu.org>
parents:
103499
diff
changeset
|
912 :type 'function |
ce2fc4a55d15
(lisp-indent-offset): Fix safe-local-variable property.
Glenn Morris <rgm@gnu.org>
parents:
103499
diff
changeset
|
913 :group 'lisp) |
98316
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
914 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
915 (defun lisp-indent-line (&optional whole-exp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
916 "Indent current line as Lisp code. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
917 With argument, indent any additional lines of the same expression |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
918 rigidly along with this one." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
919 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
920 (let ((indent (calculate-lisp-indent)) shift-amt end |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
921 (pos (- (point-max) (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
922 (beg (progn (beginning-of-line) (point)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
923 (skip-chars-forward " \t") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
924 (if (or (null indent) (looking-at "\\s<\\s<\\s<")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
925 ;; Don't alter indentation of a ;;; comment line |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
926 ;; or a line that starts in a string. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
927 (goto-char (- (point-max) pos)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
928 (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<"))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
929 ;; Single-semicolon comment lines should be indented |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
930 ;; as comment lines, not as code. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
931 (progn (indent-for-comment) (forward-char -1)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
932 (if (listp indent) (setq indent (car indent))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
933 (setq shift-amt (- indent (current-column))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
934 (if (zerop shift-amt) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
935 nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
936 (delete-region beg (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
937 (indent-to indent))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
938 ;; If initial point was within line's indentation, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
939 ;; position after the indentation. Else stay at same point in text. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
940 (if (> (- (point-max) pos) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
941 (goto-char (- (point-max) pos))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
942 ;; If desired, shift remaining lines of expression the same amount. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
943 (and whole-exp (not (zerop shift-amt)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
944 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
945 (goto-char beg) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
946 (forward-sexp 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
947 (setq end (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
948 (goto-char beg) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
949 (forward-line 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
950 (setq beg (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
951 (> end beg)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
952 (indent-code-rigidly beg end shift-amt))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
953 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
954 (defvar calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
955 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
956 (defun calculate-lisp-indent (&optional parse-start) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
957 "Return appropriate indentation for current line as Lisp code. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
958 In usual case returns an integer: the column to indent to. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
959 If the value is nil, that means don't change the indentation |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
960 because the line starts inside a string. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
961 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
962 The value can also be a list of the form (COLUMN CONTAINING-SEXP-START). |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
963 This means that following lines at the same level of indentation |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
964 should not necessarily be indented the same as this line. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
965 Then COLUMN is the column to indent to, and CONTAINING-SEXP-START |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
966 is the buffer position of the start of the containing expression." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
967 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
968 (beginning-of-line) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
969 (let ((indent-point (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
970 state paren-depth |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
971 ;; setting this to a number inhibits calling hook |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
972 (desired-indent nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
973 (retry t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
974 calculate-lisp-indent-last-sexp containing-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
975 (if parse-start |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
976 (goto-char parse-start) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
977 (beginning-of-defun)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
978 ;; Find outermost containing sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
979 (while (< (point) indent-point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
980 (setq state (parse-partial-sexp (point) indent-point 0))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
981 ;; Find innermost containing sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
982 (while (and retry |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
983 state |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
984 (> (setq paren-depth (elt state 0)) 0)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
985 (setq retry nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
986 (setq calculate-lisp-indent-last-sexp (elt state 2)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
987 (setq containing-sexp (elt state 1)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
988 ;; Position following last unclosed open. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
989 (goto-char (1+ containing-sexp)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
990 ;; Is there a complete sexp since then? |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
991 (if (and calculate-lisp-indent-last-sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
992 (> calculate-lisp-indent-last-sexp (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
993 ;; Yes, but is there a containing sexp after that? |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
994 (let ((peek (parse-partial-sexp calculate-lisp-indent-last-sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
995 indent-point 0))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
996 (if (setq retry (car (cdr peek))) (setq state peek))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
997 (if retry |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
998 nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
999 ;; Innermost containing sexp found |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1000 (goto-char (1+ containing-sexp)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1001 (if (not calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1002 ;; indent-point immediately follows open paren. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1003 ;; Don't call hook. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1004 (setq desired-indent (current-column)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1005 ;; Find the start of first element of containing sexp. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1006 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1007 (cond ((looking-at "\\s(") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1008 ;; First element of containing sexp is a list. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1009 ;; Indent under that list. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1010 ) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1011 ((> (save-excursion (forward-line 1) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1012 calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1013 ;; This is the first line to start within the containing sexp. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1014 ;; It's almost certainly a function call. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1015 (if (= (point) calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1016 ;; Containing sexp has nothing before this line |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1017 ;; except the first element. Indent under that element. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1018 nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1019 ;; Skip the first element, find start of second (the first |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1020 ;; argument of the function call) and indent under. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1021 (progn (forward-sexp 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1022 (parse-partial-sexp (point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1023 calculate-lisp-indent-last-sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1024 0 t))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1025 (backward-prefix-chars)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1026 (t |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1027 ;; Indent beneath first sexp on same line as |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1028 ;; `calculate-lisp-indent-last-sexp'. Again, it's |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1029 ;; almost certainly a function call. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1030 (goto-char calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1031 (beginning-of-line) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1032 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1033 0 t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1034 (backward-prefix-chars))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1035 ;; Point is at the point to indent under unless we are inside a string. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1036 ;; Call indentation hook except when overridden by lisp-indent-offset |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1037 ;; or if the desired indentation has already been computed. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1038 (let ((normal-indent (current-column))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1039 (cond ((elt state 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1040 ;; Inside a string, don't change indentation. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1041 nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1042 ((and (integerp lisp-indent-offset) containing-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1043 ;; Indent by constant offset |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1044 (goto-char containing-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1045 (+ (current-column) lisp-indent-offset)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1046 ;; in this case calculate-lisp-indent-last-sexp is not nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1047 (calculate-lisp-indent-last-sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1048 (or |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1049 ;; try to align the parameters of a known function |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1050 (and lisp-indent-function |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1051 (not retry) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1052 (funcall lisp-indent-function indent-point state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1053 ;; If the function has no special alignment |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1054 ;; or it does not apply to this argument, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1055 ;; try to align a constant-symbol under the last |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1056 ;; preceding constant symbol, if there is such one of |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1057 ;; the last 2 preceding symbols, in the previous |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1058 ;; uncommented line. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1059 (and (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1060 (goto-char indent-point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1061 (skip-chars-forward " \t") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1062 (looking-at ":")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1063 ;; The last sexp may not be at the indentation |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1064 ;; where it begins, so find that one, instead. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1065 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1066 (goto-char calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1067 ;; Handle prefix characters and whitespace |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1068 ;; following an open paren. (Bug#1012) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1069 (backward-prefix-chars) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1070 (while (and (not (looking-back "^[ \t]*\\|([ \t]+")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1071 (or (not containing-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1072 (< (1+ containing-sexp) (point)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1073 (forward-sexp -1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1074 (backward-prefix-chars)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1075 (setq calculate-lisp-indent-last-sexp (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1076 (> calculate-lisp-indent-last-sexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1077 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1078 (goto-char (1+ containing-sexp)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1079 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1080 (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1081 (let ((parse-sexp-ignore-comments t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1082 indent) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1083 (goto-char calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1084 (or (and (looking-at ":") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1085 (setq indent (current-column))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1086 (and (< (save-excursion (beginning-of-line) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1087 (prog2 (backward-sexp) (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1088 (looking-at ":") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1089 (setq indent (current-column)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1090 indent)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1091 ;; another symbols or constants not preceded by a constant |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1092 ;; as defined above. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1093 normal-indent)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1094 ;; in this case calculate-lisp-indent-last-sexp is nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1095 (desired-indent) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1096 (t |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1097 normal-indent)))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1098 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1099 (defun lisp-indent-function (indent-point state) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1100 "This function is the normal value of the variable `lisp-indent-function'. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1101 It is used when indenting a line within a function call, to see if the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1102 called function says anything special about how to indent the line. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1103 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1104 INDENT-POINT is the position where the user typed TAB, or equivalent. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1105 Point is located at the point to indent under (for default indentation); |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1106 STATE is the `parse-partial-sexp' state for that position. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1107 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1108 If the current line is in a call to a Lisp function |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1109 which has a non-nil property `lisp-indent-function', |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1110 that specifies how to do the indentation. The property value can be |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1111 * `defun', meaning indent `defun'-style; |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1112 * an integer N, meaning indent the first N arguments specially |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1113 like ordinary function arguments and then indent any further |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1114 arguments like a body; |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1115 * a function to call just as this function was called. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1116 If that function returns nil, that means it doesn't specify |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1117 the indentation. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1118 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1119 This function also returns nil meaning don't specify the indentation." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1120 (let ((normal-indent (current-column))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1121 (goto-char (1+ (elt state 1))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1122 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1123 (if (and (elt state 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1124 (not (looking-at "\\sw\\|\\s_"))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1125 ;; car of form doesn't seem to be a symbol |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1126 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1127 (if (not (> (save-excursion (forward-line 1) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1128 calculate-lisp-indent-last-sexp)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1129 (progn (goto-char calculate-lisp-indent-last-sexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1130 (beginning-of-line) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1131 (parse-partial-sexp (point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1132 calculate-lisp-indent-last-sexp 0 t))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1133 ;; Indent under the list or under the first sexp on the same |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1134 ;; line as calculate-lisp-indent-last-sexp. Note that first |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1135 ;; thing on that line has to be complete sexp since we are |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1136 ;; inside the innermost containing sexp. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1137 (backward-prefix-chars) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1138 (current-column)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1139 (let ((function (buffer-substring (point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1140 (progn (forward-sexp 1) (point)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1141 method) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1142 (setq method (or (get (intern-soft function) 'lisp-indent-function) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1143 (get (intern-soft function) 'lisp-indent-hook))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1144 (cond ((or (eq method 'defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1145 (and (null method) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1146 (> (length function) 3) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1147 (string-match "\\`def" function))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1148 (lisp-indent-defform state indent-point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1149 ((integerp method) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1150 (lisp-indent-specform method state |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1151 indent-point normal-indent)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1152 (method |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1153 (funcall method indent-point state))))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1154 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1155 (defcustom lisp-body-indent 2 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1156 "Number of columns to indent the second line of a `(def...)' form." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1157 :group 'lisp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1158 :type 'integer) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1159 (put 'lisp-body-indent 'safe-local-variable 'integerp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1160 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1161 (defun lisp-indent-specform (count state indent-point normal-indent) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1162 (let ((containing-form-start (elt state 1)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1163 (i count) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1164 body-indent containing-form-column) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1165 ;; Move to the start of containing form, calculate indentation |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1166 ;; to use for non-distinguished forms (> count), and move past the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1167 ;; function symbol. lisp-indent-function guarantees that there is at |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1168 ;; least one word or symbol character following open paren of containing |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1169 ;; form. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1170 (goto-char containing-form-start) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1171 (setq containing-form-column (current-column)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1172 (setq body-indent (+ lisp-body-indent containing-form-column)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1173 (forward-char 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1174 (forward-sexp 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1175 ;; Now find the start of the last form. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1176 (parse-partial-sexp (point) indent-point 1 t) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1177 (while (and (< (point) indent-point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1178 (condition-case () |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1179 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1180 (setq count (1- count)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1181 (forward-sexp 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1182 (parse-partial-sexp (point) indent-point 1 t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1183 (error nil)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1184 ;; Point is sitting on first character of last (or count) sexp. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1185 (if (> count 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1186 ;; A distinguished form. If it is the first or second form use double |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1187 ;; lisp-body-indent, else normal indent. With lisp-body-indent bound |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1188 ;; to 2 (the default), this just happens to work the same with if as |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1189 ;; the older code, but it makes unwind-protect, condition-case, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1190 ;; with-output-to-temp-buffer, et. al. much more tasteful. The older, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1191 ;; less hacked, behavior can be obtained by replacing below with |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1192 ;; (list normal-indent containing-form-start). |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1193 (if (<= (- i count) 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1194 (list (+ containing-form-column (* 2 lisp-body-indent)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1195 containing-form-start) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1196 (list normal-indent containing-form-start)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1197 ;; A non-distinguished form. Use body-indent if there are no |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1198 ;; distinguished forms and this is the first undistinguished form, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1199 ;; or if this is the first undistinguished form and the preceding |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1200 ;; distinguished form has indentation at least as great as body-indent. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1201 (if (or (and (= i 0) (= count 0)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1202 (and (= count 0) (<= body-indent normal-indent))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1203 body-indent |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1204 normal-indent)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1205 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1206 (defun lisp-indent-defform (state indent-point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1207 (goto-char (car (cdr state))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1208 (forward-line 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1209 (if (> (point) (car (cdr (cdr state)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1210 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1211 (goto-char (car (cdr state))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1212 (+ lisp-body-indent (current-column))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1213 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1214 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1215 ;; (put 'progn 'lisp-indent-function 0), say, causes progn to be indented |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1216 ;; like defun if the first form is placed on the next line, otherwise |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1217 ;; it is indented like any other form (i.e. forms line up under first). |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1218 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1219 (put 'lambda 'lisp-indent-function 'defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1220 (put 'autoload 'lisp-indent-function 'defun) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1221 (put 'progn 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1222 (put 'prog1 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1223 (put 'prog2 'lisp-indent-function 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1224 (put 'save-excursion 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1225 (put 'save-window-excursion 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1226 (put 'save-selected-window 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1227 (put 'save-restriction 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1228 (put 'save-match-data 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1229 (put 'save-current-buffer 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1230 (put 'with-current-buffer 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1231 (put 'combine-after-change-calls 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1232 (put 'with-output-to-string 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1233 (put 'with-temp-file 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1234 (put 'with-temp-buffer 'lisp-indent-function 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1235 (put 'with-temp-message 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1236 (put 'with-syntax-table 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1237 (put 'let 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1238 (put 'let* 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1239 (put 'while 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1240 (put 'if 'lisp-indent-function 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1241 (put 'read-if 'lisp-indent-function 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1242 (put 'catch 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1243 (put 'condition-case 'lisp-indent-function 2) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1244 (put 'unwind-protect 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1245 (put 'with-output-to-temp-buffer 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1246 (put 'eval-after-load 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1247 (put 'dolist 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1248 (put 'dotimes 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1249 (put 'when 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1250 (put 'unless 'lisp-indent-function 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1251 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1252 (defun indent-sexp (&optional endpos) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1253 "Indent each line of the list starting just after point. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1254 If optional arg ENDPOS is given, indent each line, stopping when |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1255 ENDPOS is encountered." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1256 (interactive) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1257 (let ((indent-stack (list nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1258 (next-depth 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1259 ;; If ENDPOS is non-nil, use nil as STARTING-POINT |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1260 ;; so that calculate-lisp-indent will find the beginning of |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1261 ;; the defun we are in. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1262 ;; If ENDPOS is nil, it is safe not to scan before point |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1263 ;; since every line we indent is more deeply nested than point is. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1264 (starting-point (if endpos nil (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1265 (last-point (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1266 last-depth bol outer-loop-done inner-loop-done state this-indent) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1267 (or endpos |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1268 ;; Get error now if we don't have a complete sexp after point. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1269 (save-excursion (forward-sexp 1))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1270 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1271 (setq outer-loop-done nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1272 (while (if endpos (< (point) endpos) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1273 (not outer-loop-done)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1274 (setq last-depth next-depth |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1275 inner-loop-done nil) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1276 ;; Parse this line so we can learn the state |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1277 ;; to indent the next line. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1278 ;; This inner loop goes through only once |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1279 ;; unless a line ends inside a string. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1280 (while (and (not inner-loop-done) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1281 (not (setq outer-loop-done (eobp)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1282 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1283 nil nil state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1284 (setq next-depth (car state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1285 ;; If the line contains a comment other than the sort |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1286 ;; that is indented like code, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1287 ;; indent it now with indent-for-comment. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1288 ;; Comments indented like code are right already. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1289 ;; In any case clear the in-comment flag in the state |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1290 ;; because parse-partial-sexp never sees the newlines. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1291 (if (car (nthcdr 4 state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1292 (progn (indent-for-comment) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1293 (end-of-line) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1294 (setcar (nthcdr 4 state) nil))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1295 ;; If this line ends inside a string, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1296 ;; go straight to next line, remaining within the inner loop, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1297 ;; and turn off the \-flag. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1298 (if (car (nthcdr 3 state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1299 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1300 (forward-line 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1301 (setcar (nthcdr 5 state) nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1302 (setq inner-loop-done t))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1303 (and endpos |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1304 (<= next-depth 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1305 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1306 (setq indent-stack (nconc indent-stack |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1307 (make-list (- next-depth) nil)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1308 last-depth (- last-depth next-depth) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1309 next-depth 0))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1310 (forward-line 1) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1311 ;; Decide whether to exit. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1312 (if endpos |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1313 ;; If we have already reached the specified end, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1314 ;; give up and do not reindent this line. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1315 (if (<= endpos (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1316 (setq outer-loop-done t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1317 ;; If no specified end, we are done if we have finished one sexp. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1318 (if (<= next-depth 0) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1319 (setq outer-loop-done t))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1320 (unless outer-loop-done |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1321 (while (> last-depth next-depth) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1322 (setq indent-stack (cdr indent-stack) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1323 last-depth (1- last-depth))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1324 (while (< last-depth next-depth) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1325 (setq indent-stack (cons nil indent-stack) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1326 last-depth (1+ last-depth))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1327 ;; Now indent the next line according |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1328 ;; to what we learned from parsing the previous one. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1329 (setq bol (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1330 (skip-chars-forward " \t") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1331 ;; But not if the line is blank, or just a comment |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1332 ;; (except for double-semi comments; indent them as usual). |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1333 (if (or (eobp) (looking-at "\\s<\\|\n")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1334 nil |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1335 (if (and (car indent-stack) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1336 (>= (car indent-stack) 0)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1337 (setq this-indent (car indent-stack)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1338 (let ((val (calculate-lisp-indent |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1339 (if (car indent-stack) (- (car indent-stack)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1340 starting-point)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1341 (if (null val) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1342 (setq this-indent val) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1343 (if (integerp val) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1344 (setcar indent-stack |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1345 (setq this-indent val)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1346 (setcar indent-stack (- (car (cdr val)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1347 (setq this-indent (car val)))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1348 (if (and this-indent (/= (current-column) this-indent)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1349 (progn (delete-region bol (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1350 (indent-to this-indent))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1351 (or outer-loop-done |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1352 (setq outer-loop-done (= (point) last-point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1353 (setq last-point (point))))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1354 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1355 (defun indent-pp-sexp (&optional arg) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1356 "Indent each line of the list starting just after point, or prettyprint it. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1357 A prefix argument specifies pretty-printing." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1358 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1359 (if arg |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1360 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1361 (save-restriction |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1362 (narrow-to-region (point) (progn (forward-sexp 1) (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1363 (pp-buffer) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1364 (goto-char (point-max)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1365 (if (eq (char-before) ?\n) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1366 (delete-char -1))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1367 (indent-sexp)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1368 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1369 ;;;; Lisp paragraph filling commands. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1370 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1371 (defcustom emacs-lisp-docstring-fill-column 65 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1372 "Value of `fill-column' to use when filling a docstring. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1373 Any non-integer value means do not use a different value of |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1374 `fill-column' when filling docstrings." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1375 :type '(choice (integer) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1376 (const :tag "Use the current `fill-column'" t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1377 :group 'lisp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1378 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1379 (defun lisp-fill-paragraph (&optional justify) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1380 "Like \\[fill-paragraph], but handle Emacs Lisp comments and docstrings. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1381 If any of the current line is a comment, fill the comment or the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1382 paragraph of it that point is in, preserving the comment's indentation |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1383 and initial semicolons." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1384 (interactive "P") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1385 (or (fill-comment-paragraph justify) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1386 ;; Since fill-comment-paragraph returned nil, that means we're not in |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1387 ;; a comment: Point is on a program line; we are interested |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1388 ;; particularly in docstring lines. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1389 ;; |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1390 ;; We bind `paragraph-start' and `paragraph-separate' temporarily. They |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1391 ;; are buffer-local, but we avoid changing them so that they can be set |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1392 ;; to make `forward-paragraph' and friends do something the user wants. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1393 ;; |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1394 ;; `paragraph-start': The `(' in the character alternative and the |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1395 ;; left-singlequote plus `(' sequence after the \\| alternative prevent |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1396 ;; sexps and backquoted sexps that follow a docstring from being filled |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1397 ;; with the docstring. This setting has the consequence of inhibiting |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1398 ;; filling many program lines that are not docstrings, which is sensible, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1399 ;; because the user probably asked to fill program lines by accident, or |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1400 ;; expecting indentation (perhaps we should try to do indenting in that |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1401 ;; case). The `;' and `:' stop the paragraph being filled at following |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1402 ;; comment lines and at keywords (e.g., in `defcustom'). Left parens are |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1403 ;; escaped to keep font-locking, filling, & paren matching in the source |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1404 ;; file happy. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1405 ;; |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1406 ;; `paragraph-separate': A clever regexp distinguishes the first line of |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1407 ;; a docstring and identifies it as a paragraph separator, so that it |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1408 ;; won't be filled. (Since the first line of documentation stands alone |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1409 ;; in some contexts, filling should not alter the contents the author has |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1410 ;; chosen.) Only the first line of a docstring begins with whitespace |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1411 ;; and a quotation mark and ends with a period or (rarely) a comma. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1412 ;; |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1413 ;; The `fill-column' is temporarily bound to |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1414 ;; `emacs-lisp-docstring-fill-column' if that value is an integer. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1415 (let ((paragraph-start (concat paragraph-start |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1416 "\\|\\s-*\\([(;:\"]\\|`(\\|#'(\\)")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1417 (paragraph-separate |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1418 (concat paragraph-separate "\\|\\s-*\".*[,\\.]$")) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1419 (fill-column (if (and (integerp emacs-lisp-docstring-fill-column) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1420 (derived-mode-p 'emacs-lisp-mode)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1421 emacs-lisp-docstring-fill-column |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1422 fill-column))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1423 (fill-paragraph justify)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1424 ;; Never return nil. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1425 t)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1426 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1427 (defun indent-code-rigidly (start end arg &optional nochange-regexp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1428 "Indent all lines of code, starting in the region, sideways by ARG columns. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1429 Does not affect lines starting inside comments or strings, assuming that |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1430 the start of the region is not inside them. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1431 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1432 Called from a program, takes args START, END, COLUMNS and NOCHANGE-REGEXP. |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1433 The last is a regexp which, if matched at the beginning of a line, |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1434 means don't indent that line." |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1435 (interactive "r\np") |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1436 (let (state) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1437 (save-excursion |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1438 (goto-char end) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1439 (setq end (point-marker)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1440 (goto-char start) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1441 (or (bolp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1442 (setq state (parse-partial-sexp (point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1443 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1444 (forward-line 1) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1445 nil nil state))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1446 (while (< (point) end) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1447 (or (car (nthcdr 3 state)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1448 (and nochange-regexp |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1449 (looking-at nochange-regexp)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1450 ;; If line does not start in string, indent it |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1451 (let ((indent (current-indentation))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1452 (delete-region (point) (progn (skip-chars-forward " \t") (point))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1453 (or (eolp) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1454 (indent-to (max 0 (+ indent arg)) 0)))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1455 (setq state (parse-partial-sexp (point) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1456 (progn |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1457 (forward-line 1) (point)) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1458 nil nil state)))))) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1459 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1460 (provide 'lisp-mode) |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1461 |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1462 ;; arch-tag: 414c7f93-c245-4b77-8ed5-ed05ef7ff1bf |
8ecc08b621cb
*** empty log message ***
Martin Rudalics <rudalics@gmx.at>
parents:
98310
diff
changeset
|
1463 ;;; lisp-mode.el ends here |