(last-sexp-toggle-display): At end of buffer, just call `newline'.
[emacs.git] / lisp / emacs-lisp / lisp-mode.el
blob6c084c409df617169cf0f0f065bf4c48b875c36d
1 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands
3 ;; Copyright (C) 1985, 1986, 1999, 2000, 2001 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: lisp, languages
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;; The base major mode for editing Lisp code (used also for Emacs Lisp).
28 ;; This mode is documented in the Emacs manual.
30 ;;; Code:
32 (defvar lisp-mode-abbrev-table nil)
34 (defvar emacs-lisp-mode-syntax-table
35 (let ((table (make-syntax-table)))
36 (let ((i 0))
37 (while (< i ?0)
38 (modify-syntax-entry i "_ " table)
39 (setq i (1+ i)))
40 (setq i (1+ ?9))
41 (while (< i ?A)
42 (modify-syntax-entry i "_ " table)
43 (setq i (1+ i)))
44 (setq i (1+ ?Z))
45 (while (< i ?a)
46 (modify-syntax-entry i "_ " table)
47 (setq i (1+ i)))
48 (setq i (1+ ?z))
49 (while (< i 128)
50 (modify-syntax-entry i "_ " table)
51 (setq i (1+ i)))
52 (modify-syntax-entry ? " " table)
53 (modify-syntax-entry ?\t " " table)
54 (modify-syntax-entry ?\f " " table)
55 (modify-syntax-entry ?\n "> " table)
56 ;; Give CR the same syntax as newline, for selective-display.
57 (modify-syntax-entry ?\^m "> " table)
58 (modify-syntax-entry ?\; "< " table)
59 (modify-syntax-entry ?` "' " table)
60 (modify-syntax-entry ?' "' " table)
61 (modify-syntax-entry ?, "' " table)
62 ;; Used to be singlequote; changed for flonums.
63 (modify-syntax-entry ?. "_ " table)
64 (modify-syntax-entry ?# "' " table)
65 (modify-syntax-entry ?\" "\" " table)
66 (modify-syntax-entry ?\\ "\\ " table)
67 (modify-syntax-entry ?\( "() " table)
68 (modify-syntax-entry ?\) ")( " table)
69 (modify-syntax-entry ?\[ "(] " table)
70 (modify-syntax-entry ?\] ")[ " table))
71 table))
73 (defvar lisp-mode-syntax-table
74 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
75 (modify-syntax-entry ?\[ "_ " table)
76 (modify-syntax-entry ?\] "_ " table)
77 (modify-syntax-entry ?# "' 14bn" table)
78 (modify-syntax-entry ?| "\" 23b" table)
79 table))
81 (define-abbrev-table 'lisp-mode-abbrev-table ())
83 (defvar lisp-imenu-generic-expression
84 (list
85 (list nil
86 (purecopy (concat "^\\s-*("
87 (eval-when-compile
88 (regexp-opt
89 '("defun" "defun*" "defsubst" "defmacro"
90 "defadvice" "define-skeleton"
91 "define-minor-mode" "define-derived-mode"
92 "define-compiler-macro" "define-modify-macro"
93 "defsetf" "define-setf-expander"
94 "define-method-combination"
95 "defgeneric" "defmethod") t))
96 "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)"))
98 (list (purecopy "Variables")
99 (purecopy (concat "^\\s-*("
100 (eval-when-compile
101 (regexp-opt
102 '("defvar" "defconst" "defconstant" "defcustom"
103 "defparameter" "define-symbol-macro") t))
104 "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)"))
106 (list (purecopy "Types")
107 (purecopy (concat "^\\s-*("
108 (eval-when-compile
109 (regexp-opt
110 '("defgroup" "deftheme" "deftype" "defstruct"
111 "defclass" "define-condition" "define-widget"
112 "defface" "defpackage") t))
113 "\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)"))
116 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.")
118 ;; This was originally in autoload.el and is still used there.
119 (put 'autoload 'doc-string-elt 3)
120 (put 'defun 'doc-string-elt 3)
121 (put 'defun* 'doc-string-elt 3)
122 (put 'defvar 'doc-string-elt 3)
123 (put 'defcustom 'doc-string-elt 3)
124 (put 'deftheme 'doc-string-elt 2)
125 (put 'defconst 'doc-string-elt 3)
126 (put 'defmacro 'doc-string-elt 3)
127 (put 'defmacro* 'doc-string-elt 3)
128 (put 'defsubst 'doc-string-elt 3)
129 (put 'define-skeleton 'doc-string-elt 2)
130 (put 'define-derived-mode 'doc-string-elt 4)
131 (put 'easy-mmode-define-minor-mode 'doc-string-elt 2)
132 (put 'define-minor-mode 'doc-string-elt 2)
133 (put 'define-generic-mode 'doc-string-elt 7)
134 ;; define-global-mode has no explicit docstring.
135 (put 'easy-mmode-define-global-mode 'doc-string-elt 0)
136 (put 'define-ibuffer-filter 'doc-string-elt 2)
137 (put 'define-ibuffer-op 'doc-string-elt 3)
138 (put 'define-ibuffer-sorter 'doc-string-elt 2)
140 (defun lisp-font-lock-syntactic-face-function (state)
141 (if (nth 3 state)
142 (if (and (eq (nth 0 state) 1)
143 ;; This might be a docstring.
144 (save-excursion
145 (let ((n 0))
146 (goto-char (nth 8 state))
147 (condition-case nil
148 (while (progn (backward-sexp 1) (setq n (1+ n))))
149 (scan-error nil))
150 (when (> n 0)
151 (let ((sym (intern-soft
152 (buffer-substring
153 (point) (progn (forward-sexp 1) (point))))))
154 (eq n (or (get sym 'doc-string-elt) 3)))))))
155 font-lock-doc-face
156 font-lock-string-face)
157 font-lock-comment-face))
159 ;; The LISP-SYNTAX argument is used by code in inf-lisp.el and is
160 ;; (uselessly) passed from pp.el, chistory.el, gnus-kill.el and score-mode.el
161 (defun lisp-mode-variables (&optional lisp-syntax)
162 (when lisp-syntax
163 (set-syntax-table lisp-mode-syntax-table))
164 (setq local-abbrev-table lisp-mode-abbrev-table)
165 (make-local-variable 'paragraph-ignore-fill-prefix)
166 (setq paragraph-ignore-fill-prefix t)
167 (make-local-variable 'fill-paragraph-function)
168 (setq fill-paragraph-function 'lisp-fill-paragraph)
169 ;; Adaptive fill mode gets in the way of auto-fill,
170 ;; and should make no difference for explicit fill
171 ;; because lisp-fill-paragraph should do the job.
172 ;; I believe that newcomment's auto-fill code properly deals with it -stef
173 ;;(set (make-local-variable 'adaptive-fill-mode) nil)
174 (make-local-variable 'normal-auto-fill-function)
175 (setq normal-auto-fill-function 'lisp-mode-auto-fill)
176 (make-local-variable 'indent-line-function)
177 (setq indent-line-function 'lisp-indent-line)
178 (make-local-variable 'indent-region-function)
179 (setq indent-region-function 'lisp-indent-region)
180 (make-local-variable 'parse-sexp-ignore-comments)
181 (setq parse-sexp-ignore-comments t)
182 (make-local-variable 'outline-regexp)
183 (setq outline-regexp ";;;;* \\|(")
184 (make-local-variable 'outline-level)
185 (setq outline-level 'lisp-outline-level)
186 (make-local-variable 'comment-start)
187 (setq comment-start ";")
188 (make-local-variable 'comment-start-skip)
189 ;; Look within the line for a ; following an even number of backslashes
190 ;; after either a non-backslash or the line beginning.
191 (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
192 (make-local-variable 'comment-add)
193 (setq comment-add 1) ;default to `;;' in comment-region
194 (make-local-variable 'comment-column)
195 (setq comment-column 40)
196 (make-local-variable 'comment-indent-function)
197 (setq comment-indent-function 'lisp-comment-indent)
198 (make-local-variable 'imenu-generic-expression)
199 (setq imenu-generic-expression lisp-imenu-generic-expression)
200 (make-local-variable 'multibyte-syntax-as-symbol)
201 (setq multibyte-syntax-as-symbol t)
202 (set (make-local-variable 'syntax-begin-function) 'beginning-of-defun)
203 (setq font-lock-defaults
204 '((lisp-font-lock-keywords
205 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
206 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
207 (font-lock-mark-block-function . mark-defun)
208 (font-lock-syntactic-face-function
209 . lisp-font-lock-syntactic-face-function))))
211 (defun lisp-outline-level ()
212 "Lisp mode `outline-level' function."
213 (if (looking-at "(")
214 1000
215 (looking-at outline-regexp)
216 (- (match-end 0) (match-beginning 0))))
219 (defvar lisp-mode-shared-map
220 (let ((map (make-sparse-keymap)))
221 (define-key map "\t" 'lisp-indent-line)
222 (define-key map "\e\C-q" 'indent-sexp)
223 (define-key map "\177" 'backward-delete-char-untabify)
224 ;; This gets in the way when viewing a Lisp file in view-mode. As
225 ;; long as [backspace] is mapped into DEL via the
226 ;; function-key-map, this should remain disabled!!
227 ;;;(define-key map [backspace] 'backward-delete-char-untabify)
228 map)
229 "Keymap for commands shared by all sorts of Lisp modes.")
231 (defvar emacs-lisp-mode-map ()
232 "Keymap for Emacs Lisp mode.
233 All commands in `lisp-mode-shared-map' are inherited by this map.")
235 (if emacs-lisp-mode-map
237 (let ((map (make-sparse-keymap "Emacs-Lisp")))
238 (setq emacs-lisp-mode-map (make-sparse-keymap))
239 (set-keymap-parent emacs-lisp-mode-map lisp-mode-shared-map)
240 (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol)
241 (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun)
242 (define-key emacs-lisp-mode-map [menu-bar] (make-sparse-keymap))
243 (define-key emacs-lisp-mode-map [menu-bar emacs-lisp]
244 (cons "Emacs-Lisp" map))
245 (define-key map [edebug-defun]
246 '("Instrument Function for Debugging" . edebug-defun))
247 (define-key map [byte-recompile]
248 '("Byte-recompile Directory..." . byte-recompile-directory))
249 (define-key map [emacs-byte-compile-and-load]
250 '("Byte-compile And Load" . emacs-lisp-byte-compile-and-load))
251 (define-key map [byte-compile]
252 '("Byte-compile This File" . emacs-lisp-byte-compile))
253 (define-key map [separator-eval] '("--"))
254 (define-key map [eval-buffer] '("Evaluate Buffer" . eval-current-buffer))
255 (define-key map [eval-region] '("Evaluate Region" . eval-region))
256 (define-key map [eval-sexp] '("Evaluate Last S-expression" . eval-last-sexp))
257 (define-key map [separator-format] '("--"))
258 (define-key map [comment-region] '("Comment Out Region" . comment-region))
259 (define-key map [indent-region] '("Indent Region" . indent-region))
260 (define-key map [indent-line] '("Indent Line" . lisp-indent-line))
261 (put 'eval-region 'menu-enable 'mark-active)
262 (put 'comment-region 'menu-enable 'mark-active)
263 (put 'indent-region 'menu-enable 'mark-active)))
265 (defun emacs-lisp-byte-compile ()
266 "Byte compile the file containing the current buffer."
267 (interactive)
268 (if buffer-file-name
269 (byte-compile-file buffer-file-name)
270 (error "The buffer must be saved in a file first")))
272 (defun emacs-lisp-byte-compile-and-load ()
273 "Byte-compile the current file (if it has changed), then load compiled code."
274 (interactive)
275 (or buffer-file-name
276 (error "The buffer must be saved in a file first"))
277 (require 'bytecomp)
278 ;; Recompile if file or buffer has changed since last compilation.
279 (if (and (buffer-modified-p)
280 (y-or-n-p (format "Save buffer %s first? " (buffer-name))))
281 (save-buffer))
282 (let ((compiled-file-name (byte-compile-dest-file buffer-file-name)))
283 (if (file-newer-than-file-p compiled-file-name buffer-file-name)
284 (load-file compiled-file-name)
285 (byte-compile-file buffer-file-name t))))
287 (defcustom emacs-lisp-mode-hook nil
288 "Hook run when entering Emacs Lisp mode."
289 :options '(turn-on-eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
290 :type 'hook
291 :group 'lisp)
293 (defcustom lisp-mode-hook nil
294 "Hook run when entering Lisp mode."
295 :options '(imenu-add-menubar-index)
296 :type 'hook
297 :group 'lisp)
299 (defcustom lisp-interaction-mode-hook nil
300 "Hook run when entering Lisp Interaction mode."
301 :options '(turn-on-eldoc-mode)
302 :type 'hook
303 :group 'lisp)
305 (defun emacs-lisp-mode ()
306 "Major mode for editing Lisp code to run in Emacs.
307 Commands:
308 Delete converts tabs to spaces as it moves back.
309 Blank lines separate paragraphs. Semicolons start comments.
310 \\{emacs-lisp-mode-map}
311 Entry to this mode calls the value of `emacs-lisp-mode-hook'
312 if that value is non-nil."
313 (interactive)
314 (kill-all-local-variables)
315 (use-local-map emacs-lisp-mode-map)
316 (set-syntax-table emacs-lisp-mode-syntax-table)
317 (setq major-mode 'emacs-lisp-mode)
318 (setq mode-name "Emacs-Lisp")
319 (lisp-mode-variables)
320 (setq imenu-case-fold-search nil)
321 (run-hooks 'emacs-lisp-mode-hook))
323 (defvar lisp-mode-map
324 (let ((map (make-sparse-keymap)))
325 (set-keymap-parent map lisp-mode-shared-map)
326 (define-key map "\e\C-x" 'lisp-eval-defun)
327 (define-key map "\C-c\C-z" 'run-lisp)
328 map)
329 "Keymap for ordinary Lisp mode.
330 All commands in `lisp-mode-shared-map' are inherited by this map.")
332 (defun lisp-mode ()
333 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
334 Commands:
335 Delete converts tabs to spaces as it moves back.
336 Blank lines separate paragraphs. Semicolons start comments.
337 \\{lisp-mode-map}
338 Note that `run-lisp' may be used either to start an inferior Lisp job
339 or to switch back to an existing one.
341 Entry to this mode calls the value of `lisp-mode-hook'
342 if that value is non-nil."
343 (interactive)
344 (kill-all-local-variables)
345 (use-local-map lisp-mode-map)
346 (setq major-mode 'lisp-mode)
347 (setq mode-name "Lisp")
348 (lisp-mode-variables)
349 (make-local-variable 'comment-start-skip)
350 (setq comment-start-skip
351 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
352 (make-local-variable 'font-lock-keywords-case-fold-search)
353 (setq font-lock-keywords-case-fold-search t)
354 (setq imenu-case-fold-search t)
355 (set-syntax-table lisp-mode-syntax-table)
356 (run-hooks 'lisp-mode-hook))
358 ;; This will do unless inf-lisp.el is loaded.
359 (defun lisp-eval-defun (&optional and-go)
360 "Send the current defun to the Lisp process made by \\[run-lisp]."
361 (interactive)
362 (error "Process lisp does not exist"))
364 (defvar lisp-interaction-mode-map
365 (let ((map (make-sparse-keymap)))
366 (set-keymap-parent map lisp-mode-shared-map)
367 (define-key map "\e\C-x" 'eval-defun)
368 (define-key map "\e\t" 'lisp-complete-symbol)
369 (define-key map "\n" 'eval-print-last-sexp)
370 map)
371 "Keymap for Lisp Interaction mode.
372 All commands in `lisp-mode-shared-map' are inherited by this map.")
374 (defvar lisp-interaction-mode-abbrev-table lisp-mode-abbrev-table)
375 (define-derived-mode lisp-interaction-mode emacs-lisp-mode "Lisp Interaction"
376 "Major mode for typing and evaluating Lisp forms.
377 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression
378 before point, and prints its value into the buffer, advancing point.
379 Note that printing is controlled by `eval-expression-print-length'
380 and `eval-expression-print-level'.
382 Commands:
383 Delete converts tabs to spaces as it moves back.
384 Paragraphs are separated only by blank lines.
385 Semicolons start comments.
386 \\{lisp-interaction-mode-map}
387 Entry to this mode calls the value of `lisp-interaction-mode-hook'
388 if that value is non-nil.")
390 (defun eval-print-last-sexp ()
391 "Evaluate sexp before point; print value into current buffer.
393 Note that printing the result is controlled by the variables
394 `eval-expression-print-length' and `eval-expression-print-level',
395 which see."
396 (interactive)
397 (let ((standard-output (current-buffer)))
398 (terpri)
399 (eval-last-sexp t)
400 (terpri)))
403 (defun last-sexp-setup-props (beg end value alt1 alt2)
404 "Set up text properties for the output of `eval-last-sexp-1'.
405 BEG and END are the start and end of the output in current-buffer.
406 VALUE is the Lisp value printed, ALT1 and ALT2 are strings for the
407 alternative printed representations that can be displayed."
408 (let ((map (make-sparse-keymap)))
409 (define-key map "\C-m" 'last-sexp-toggle-display)
410 (define-key map [down-mouse-2] 'mouse-set-point)
411 (define-key map [mouse-2] 'last-sexp-toggle-display)
412 (add-text-properties
413 beg end
414 `(printed-value (,value ,alt1 ,alt2)
415 mouse-face highlight
416 keymap ,map
417 help-echo "RET, mouse-2: toggle abbreviated display"
418 rear-nonsticky (mouse-face keymap help-echo
419 printed-value)))))
422 (defun last-sexp-toggle-display (&optional arg)
423 "Toggle between abbreviated and unabbreviated printed representations."
424 (interactive "P")
425 ;; Normally this command won't be called at end of line.
426 ;; But when the end of the line is also the end of the buffer,
427 ;; it does get called. For consistency, pretend it was not called.
428 (if (eobp)
429 (newline arg)
430 (let ((value (get-text-property (point) 'printed-value)))
431 (when value
432 (let ((beg (or (previous-single-property-change (min (point-max) (1+ (point)))
433 'printed-value)
434 (point)))
435 (end (or (next-single-char-property-change (point) 'printed-value) (point)))
436 (standard-output (current-buffer))
437 (point (point)))
438 (delete-region beg end)
439 (insert (nth 1 value))
440 (last-sexp-setup-props beg (point)
441 (nth 0 value)
442 (nth 2 value)
443 (nth 1 value))
444 (goto-char (min (point-max) point)))))))
446 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
447 "Evaluate sexp before point; print value in minibuffer.
448 With argument, print output into current buffer."
449 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t)))
450 (let ((value
451 (eval (let ((stab (syntax-table))
452 (opoint (point))
453 ignore-quotes
454 expr)
455 (unwind-protect
456 (save-excursion
457 (set-syntax-table emacs-lisp-mode-syntax-table)
458 ;; If this sexp appears to be enclosed in `...'
459 ;; then ignore the surrounding quotes.
460 (setq ignore-quotes
461 (or (eq (following-char) ?\')
462 (eq (preceding-char) ?\')))
463 (forward-sexp -1)
464 ;; If we were after `?\e' (or similar case),
465 ;; use the whole thing, not just the `e'.
466 (when (eq (preceding-char) ?\\)
467 (forward-char -1)
468 (when (eq (preceding-char) ??)
469 (forward-char -1)))
471 ;; Skip over `#N='s.
472 (when (eq (preceding-char) ?=)
473 (let (labeled-p)
474 (save-excursion
475 (skip-chars-backward "0-9#=")
476 (setq labeled-p (looking-at "\\(#[0-9]+=\\)+")))
477 (when labeled-p
478 (forward-sexp -1))))
480 (save-restriction
481 ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in
482 ;; `variable' so that the value is returned, not the
483 ;; name
484 (if (and ignore-quotes
485 (eq (following-char) ?`))
486 (forward-char))
487 (narrow-to-region (point-min) opoint)
488 (setq expr (read (current-buffer)))
489 ;; If it's an (interactive ...) form, it's more
490 ;; useful to show how an interactive call would
491 ;; use it.
492 (and (consp expr)
493 (eq (car expr) 'interactive)
494 (setq expr
495 (list 'call-interactively
496 (list 'quote
497 (list 'lambda
498 '(&rest args)
499 expr
500 'args)))))
501 expr))
502 (set-syntax-table stab))))))
503 (let ((unabbreviated (let ((print-length nil) (print-level nil))
504 (prin1-to-string value)))
505 (print-length eval-expression-print-length)
506 (print-level eval-expression-print-level)
507 (beg (point))
508 end)
509 (prog1
510 (prin1 value)
511 (setq end (point))
512 (when (and (bufferp standard-output)
513 (or (not (null print-length))
514 (not (null print-level)))
515 (not (string= unabbreviated
516 (buffer-substring-no-properties beg end))))
517 (last-sexp-setup-props beg end value
518 unabbreviated
519 (buffer-substring-no-properties beg end))
520 ))))))
523 (defun eval-last-sexp (eval-last-sexp-arg-internal)
524 "Evaluate sexp before point; print value in minibuffer.
525 Interactively, with prefix argument, print output into current buffer."
526 (interactive "P")
527 (if (null eval-expression-debug-on-error)
528 (eval-last-sexp-1 eval-last-sexp-arg-internal)
529 (let ((old-value (make-symbol "t")) new-value value)
530 (let ((debug-on-error old-value))
531 (setq value (eval-last-sexp-1 eval-last-sexp-arg-internal))
532 (setq new-value debug-on-error))
533 (unless (eq old-value new-value)
534 (setq debug-on-error new-value))
535 value)))
537 (defun eval-defun-1 (form)
538 "Change defvar into defconst within FORM.
539 Likewise for other constructs as necessary."
540 ;; The code in edebug-defun should be consistent with this, but not
541 ;; the same, since this gets a macroexpended form.
542 (cond ((not (listp form))
543 form)
544 ((and (eq (car form) 'defvar)
545 (cdr-safe (cdr-safe form)))
546 ;; Force variable to be bound.
547 (cons 'defconst (cdr form)))
548 ;; `defcustom' is now macroexpanded to
549 ;; `custom-declare-variable' with a quoted value arg.
550 ((and (eq (car form) 'custom-declare-variable)
551 (default-boundp (eval (nth 1 form))))
552 ;; Force variable to be bound.
553 (set-default (eval (nth 1 form)) (eval (nth 1 (nth 2 form))))
554 form)
555 ((eq (car form) 'progn)
556 (cons 'progn (mapcar 'eval-defun-1 (cdr form))))
557 (t form)))
559 (defun eval-defun-2 ()
560 "Evaluate defun that point is in or before.
561 The value is displayed in the minibuffer.
562 If the current defun is actually a call to `defvar',
563 then reset the variable using the initial value expression
564 even if the variable already has some other value.
565 \(Normally `defvar' does not change the variable's value
566 if it already has a value.\)
568 With argument, insert value in current buffer after the defun.
569 Return the result of evaluation."
570 (interactive "P")
571 (let ((debug-on-error eval-expression-debug-on-error)
572 (print-length eval-expression-print-length)
573 (print-level eval-expression-print-level))
574 (save-excursion
575 ;; Arrange for eval-region to "read" the (possibly) altered form.
576 ;; eval-region handles recording which file defines a function or
577 ;; variable. Re-written using `apply' to avoid capturing
578 ;; variables like `end'.
579 (apply
580 #'eval-region
581 (let ((standard-output t)
582 beg end form)
583 ;; Read the form from the buffer, and record where it ends.
584 (save-excursion
585 (end-of-defun)
586 (beginning-of-defun)
587 (setq beg (point))
588 (setq form (read (current-buffer)))
589 (setq end (point)))
590 ;; Alter the form if necessary, changing defvar into defconst, etc.
591 (setq form (eval-defun-1 (macroexpand form)))
592 (list beg end standard-output
593 `(lambda (ignore)
594 ;; Skipping to the end of the specified region
595 ;; will make eval-region return.
596 (goto-char ,end)
597 ',form))))))
598 ;; The result of evaluation has been put onto VALUES. So return it.
599 (car values))
601 (defun eval-defun (edebug-it)
602 "Evaluate the top-level form containing point, or after point.
604 If the current defun is actually a call to `defvar' or `defcustom',
605 evaluating it this way resets the variable using its initial value
606 expression even if the variable already has some other value.
607 \(Normally `defvar' and `defcustom' do not alter the value if there
608 already is one.)
610 With a prefix argument, instrument the code for Edebug.
612 If acting on a `defun' for FUNCTION, and the function was
613 instrumented, `Edebug: FUNCTION' is printed in the minibuffer. If not
614 instrumented, just FUNCTION is printed.
616 If not acting on a `defun', the result of evaluation is displayed in
617 the minibuffer. This display is controlled by the variables
618 `eval-expression-print-length' and `eval-expression-print-level',
619 which see."
620 (interactive "P")
621 (cond (edebug-it
622 (require 'edebug)
623 (eval-defun (not edebug-all-defs)))
625 (if (null eval-expression-debug-on-error)
626 (eval-defun-2)
627 (let ((old-value (make-symbol "t")) new-value value)
628 (let ((debug-on-error old-value))
629 (setq value (eval-defun-2))
630 (setq new-value debug-on-error))
631 (unless (eq old-value new-value)
632 (setq debug-on-error new-value))
633 value)))))
636 (defun lisp-comment-indent ()
637 (if (looking-at "\\s<\\s<\\s<")
638 (current-column)
639 (if (looking-at "\\s<\\s<")
640 (let ((tem (or (calculate-lisp-indent) (current-column))))
641 (if (listp tem) (car tem) tem))
642 (skip-chars-backward " \t")
643 (max (if (bolp) 0 (1+ (current-column)))
644 comment-column))))
646 ;; This function just forces a more costly detection of comments (using
647 ;; parse-partial-sexp from beginning-of-defun). I.e. It avoids the problem of
648 ;; taking a `;' inside a string started on another line for a comment starter.
649 ;; Note: `newcomment' gets it right in 99% of the cases if you're using
650 ;; font-lock, anyway, so we could get rid of it. -stef
651 (defun lisp-mode-auto-fill ()
652 (if (> (current-column) (current-fill-column))
653 (if (save-excursion
654 (nth 4 (syntax-ppss (point))))
655 (do-auto-fill)
656 (unless (and (boundp 'comment-auto-fill-only-comments)
657 comment-auto-fill-only-comments)
658 (let ((comment-start nil) (comment-start-skip nil))
659 (do-auto-fill))))))
661 (defvar lisp-indent-offset nil
662 "If non-nil, indent second line of expressions that many more columns.")
663 (defvar lisp-indent-function 'lisp-indent-function)
665 (defun lisp-indent-line (&optional whole-exp)
666 "Indent current line as Lisp code.
667 With argument, indent any additional lines of the same expression
668 rigidly along with this one."
669 (interactive "P")
670 (let ((indent (calculate-lisp-indent)) shift-amt end
671 (pos (- (point-max) (point)))
672 (beg (progn (beginning-of-line) (point))))
673 (skip-chars-forward " \t")
674 (if (or (null indent) (looking-at "\\s<\\s<\\s<"))
675 ;; Don't alter indentation of a ;;; comment line
676 ;; or a line that starts in a string.
677 (goto-char (- (point-max) pos))
678 (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<")))
679 ;; Single-semicolon comment lines should be indented
680 ;; as comment lines, not as code.
681 (progn (indent-for-comment) (forward-char -1))
682 (if (listp indent) (setq indent (car indent)))
683 (setq shift-amt (- indent (current-column)))
684 (if (zerop shift-amt)
686 (delete-region beg (point))
687 (indent-to indent)))
688 ;; If initial point was within line's indentation,
689 ;; position after the indentation. Else stay at same point in text.
690 (if (> (- (point-max) pos) (point))
691 (goto-char (- (point-max) pos)))
692 ;; If desired, shift remaining lines of expression the same amount.
693 (and whole-exp (not (zerop shift-amt))
694 (save-excursion
695 (goto-char beg)
696 (forward-sexp 1)
697 (setq end (point))
698 (goto-char beg)
699 (forward-line 1)
700 (setq beg (point))
701 (> end beg))
702 (indent-code-rigidly beg end shift-amt)))))
704 (defvar calculate-lisp-indent-last-sexp)
706 (defun calculate-lisp-indent (&optional parse-start)
707 "Return appropriate indentation for current line as Lisp code.
708 In usual case returns an integer: the column to indent to.
709 If the value is nil, that means don't change the indentation
710 because the line starts inside a string.
712 The value can also be a list of the form (COLUMN CONTAINING-SEXP-START).
713 This means that following lines at the same level of indentation
714 should not necessarily be indented the same as this line.
715 Then COLUMN is the column to indent to, and CONTAINING-SEXP-START
716 is the buffer position of the start of the containing expression."
717 (save-excursion
718 (beginning-of-line)
719 (let ((indent-point (point))
720 state paren-depth
721 ;; setting this to a number inhibits calling hook
722 (desired-indent nil)
723 (retry t)
724 calculate-lisp-indent-last-sexp containing-sexp)
725 (if parse-start
726 (goto-char parse-start)
727 (beginning-of-defun))
728 ;; Find outermost containing sexp
729 (while (< (point) indent-point)
730 (setq state (parse-partial-sexp (point) indent-point 0)))
731 ;; Find innermost containing sexp
732 (while (and retry
733 state
734 (> (setq paren-depth (elt state 0)) 0))
735 (setq retry nil)
736 (setq calculate-lisp-indent-last-sexp (elt state 2))
737 (setq containing-sexp (elt state 1))
738 ;; Position following last unclosed open.
739 (goto-char (1+ containing-sexp))
740 ;; Is there a complete sexp since then?
741 (if (and calculate-lisp-indent-last-sexp
742 (> calculate-lisp-indent-last-sexp (point)))
743 ;; Yes, but is there a containing sexp after that?
744 (let ((peek (parse-partial-sexp calculate-lisp-indent-last-sexp
745 indent-point 0)))
746 (if (setq retry (car (cdr peek))) (setq state peek)))))
747 (if retry
749 ;; Innermost containing sexp found
750 (goto-char (1+ containing-sexp))
751 (if (not calculate-lisp-indent-last-sexp)
752 ;; indent-point immediately follows open paren.
753 ;; Don't call hook.
754 (setq desired-indent (current-column))
755 ;; Find the start of first element of containing sexp.
756 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
757 (cond ((looking-at "\\s(")
758 ;; First element of containing sexp is a list.
759 ;; Indent under that list.
761 ((> (save-excursion (forward-line 1) (point))
762 calculate-lisp-indent-last-sexp)
763 ;; This is the first line to start within the containing sexp.
764 ;; It's almost certainly a function call.
765 (if (= (point) calculate-lisp-indent-last-sexp)
766 ;; Containing sexp has nothing before this line
767 ;; except the first element. Indent under that element.
769 ;; Skip the first element, find start of second (the first
770 ;; argument of the function call) and indent under.
771 (progn (forward-sexp 1)
772 (parse-partial-sexp (point)
773 calculate-lisp-indent-last-sexp
774 0 t)))
775 (backward-prefix-chars))
777 ;; Indent beneath first sexp on same line as
778 ;; `calculate-lisp-indent-last-sexp'. Again, it's
779 ;; almost certainly a function call.
780 (goto-char calculate-lisp-indent-last-sexp)
781 (beginning-of-line)
782 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp
783 0 t)
784 (backward-prefix-chars)))))
785 ;; Point is at the point to indent under unless we are inside a string.
786 ;; Call indentation hook except when overridden by lisp-indent-offset
787 ;; or if the desired indentation has already been computed.
788 (let ((normal-indent (current-column)))
789 (cond ((elt state 3)
790 ;; Inside a string, don't change indentation.
791 nil)
792 ((and (integerp lisp-indent-offset) containing-sexp)
793 ;; Indent by constant offset
794 (goto-char containing-sexp)
795 (+ (current-column) lisp-indent-offset))
796 (desired-indent)
797 ((and (boundp 'lisp-indent-function)
798 lisp-indent-function
799 (not retry))
800 (or (funcall lisp-indent-function indent-point state)
801 normal-indent))
803 normal-indent))))))
805 (defun lisp-indent-function (indent-point state)
806 "This function is the normal value of the variable `lisp-indent-function'.
807 It is used when indenting a line within a function call, to see if the
808 called function says anything special about how to indent the line.
810 INDENT-POINT is the position where the user typed TAB, or equivalent.
811 Point is located at the point to indent under (for default indentation);
812 STATE is the `parse-partial-sexp' state for that position.
814 If the current line is in a call to a Lisp function
815 which has a non-nil property `lisp-indent-function',
816 that specifies how to do the indentation. The property value can be
817 * `defun', meaning indent `defun'-style;
818 * an integer N, meaning indent the first N arguments specially
819 like ordinary function arguments and then indent any further
820 aruments like a body;
821 * a function to call just as this function was called.
822 If that function returns nil, that means it doesn't specify
823 the indentation.
825 This function also returns nil meaning don't specify the indentation."
826 (let ((normal-indent (current-column)))
827 (goto-char (1+ (elt state 1)))
828 (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
829 (if (and (elt state 2)
830 (not (looking-at "\\sw\\|\\s_")))
831 ;; car of form doesn't seem to be a symbol
832 (progn
833 (if (not (> (save-excursion (forward-line 1) (point))
834 calculate-lisp-indent-last-sexp))
835 (progn (goto-char calculate-lisp-indent-last-sexp)
836 (beginning-of-line)
837 (parse-partial-sexp (point)
838 calculate-lisp-indent-last-sexp 0 t)))
839 ;; Indent under the list or under the first sexp on the same
840 ;; line as calculate-lisp-indent-last-sexp. Note that first
841 ;; thing on that line has to be complete sexp since we are
842 ;; inside the innermost containing sexp.
843 (backward-prefix-chars)
844 (current-column))
845 (let ((function (buffer-substring (point)
846 (progn (forward-sexp 1) (point))))
847 method)
848 (setq method (or (get (intern-soft function) 'lisp-indent-function)
849 (get (intern-soft function) 'lisp-indent-hook)))
850 (cond ((or (eq method 'defun)
851 (and (null method)
852 (> (length function) 3)
853 (string-match "\\`def" function)))
854 (lisp-indent-defform state indent-point))
855 ((integerp method)
856 (lisp-indent-specform method state
857 indent-point normal-indent))
858 (method
859 (funcall method state indent-point)))))))
861 (defvar lisp-body-indent 2
862 "Number of columns to indent the second line of a `(def...)' form.")
864 (defun lisp-indent-specform (count state indent-point normal-indent)
865 (let ((containing-form-start (elt state 1))
866 (i count)
867 body-indent containing-form-column)
868 ;; Move to the start of containing form, calculate indentation
869 ;; to use for non-distinguished forms (> count), and move past the
870 ;; function symbol. lisp-indent-function guarantees that there is at
871 ;; least one word or symbol character following open paren of containing
872 ;; form.
873 (goto-char containing-form-start)
874 (setq containing-form-column (current-column))
875 (setq body-indent (+ lisp-body-indent containing-form-column))
876 (forward-char 1)
877 (forward-sexp 1)
878 ;; Now find the start of the last form.
879 (parse-partial-sexp (point) indent-point 1 t)
880 (while (and (< (point) indent-point)
881 (condition-case ()
882 (progn
883 (setq count (1- count))
884 (forward-sexp 1)
885 (parse-partial-sexp (point) indent-point 1 t))
886 (error nil))))
887 ;; Point is sitting on first character of last (or count) sexp.
888 (if (> count 0)
889 ;; A distinguished form. If it is the first or second form use double
890 ;; lisp-body-indent, else normal indent. With lisp-body-indent bound
891 ;; to 2 (the default), this just happens to work the same with if as
892 ;; the older code, but it makes unwind-protect, condition-case,
893 ;; with-output-to-temp-buffer, et. al. much more tasteful. The older,
894 ;; less hacked, behavior can be obtained by replacing below with
895 ;; (list normal-indent containing-form-start).
896 (if (<= (- i count) 1)
897 (list (+ containing-form-column (* 2 lisp-body-indent))
898 containing-form-start)
899 (list normal-indent containing-form-start))
900 ;; A non-distinguished form. Use body-indent if there are no
901 ;; distinguished forms and this is the first undistinguished form,
902 ;; or if this is the first undistinguished form and the preceding
903 ;; distinguished form has indentation at least as great as body-indent.
904 (if (or (and (= i 0) (= count 0))
905 (and (= count 0) (<= body-indent normal-indent)))
906 body-indent
907 normal-indent))))
909 (defun lisp-indent-defform (state indent-point)
910 (goto-char (car (cdr state)))
911 (forward-line 1)
912 (if (> (point) (car (cdr (cdr state))))
913 (progn
914 (goto-char (car (cdr state)))
915 (+ lisp-body-indent (current-column)))))
918 ;; (put 'progn 'lisp-indent-function 0), say, causes progn to be indented
919 ;; like defun if the first form is placed on the next line, otherwise
920 ;; it is indented like any other form (i.e. forms line up under first).
922 (put 'lambda 'lisp-indent-function 'defun)
923 (put 'autoload 'lisp-indent-function 'defun)
924 (put 'progn 'lisp-indent-function 0)
925 (put 'prog1 'lisp-indent-function 1)
926 (put 'prog2 'lisp-indent-function 2)
927 (put 'save-excursion 'lisp-indent-function 0)
928 (put 'save-window-excursion 'lisp-indent-function 0)
929 (put 'save-selected-window 'lisp-indent-function 0)
930 (put 'save-restriction 'lisp-indent-function 0)
931 (put 'save-match-data 'lisp-indent-function 0)
932 (put 'save-current-buffer 'lisp-indent-function 0)
933 (put 'with-current-buffer 'lisp-indent-function 1)
934 (put 'combine-after-change-calls 'lisp-indent-function 0)
935 (put 'with-output-to-string 'lisp-indent-function 0)
936 (put 'with-temp-file 'lisp-indent-function 1)
937 (put 'with-temp-buffer 'lisp-indent-function 0)
938 (put 'with-temp-message 'lisp-indent-function 1)
939 (put 'with-syntax-table 'lisp-indent-function 1)
940 (put 'let 'lisp-indent-function 1)
941 (put 'let* 'lisp-indent-function 1)
942 (put 'while 'lisp-indent-function 1)
943 (put 'if 'lisp-indent-function 2)
944 (put 'read-if 'lisp-indent-function 2)
945 (put 'catch 'lisp-indent-function 1)
946 (put 'condition-case 'lisp-indent-function 2)
947 (put 'unwind-protect 'lisp-indent-function 1)
948 (put 'with-output-to-temp-buffer 'lisp-indent-function 1)
949 (put 'eval-after-load 'lisp-indent-function 1)
950 (put 'dolist 'lisp-indent-function 1)
951 (put 'dotimes 'lisp-indent-function 1)
952 (put 'when 'lisp-indent-function 1)
953 (put 'unless 'lisp-indent-function 1)
955 (defun indent-sexp (&optional endpos)
956 "Indent each line of the list starting just after point.
957 If optional arg ENDPOS is given, indent each line, stopping when
958 ENDPOS is encountered."
959 (interactive)
960 (let ((indent-stack (list nil))
961 (next-depth 0)
962 ;; If ENDPOS is non-nil, use nil as STARTING-POINT
963 ;; so that calculate-lisp-indent will find the beginning of
964 ;; the defun we are in.
965 ;; If ENDPOS is nil, it is safe not to scan before point
966 ;; since every line we indent is more deeply nested than point is.
967 (starting-point (if endpos nil (point)))
968 (last-point (point))
969 last-depth bol outer-loop-done inner-loop-done state this-indent)
970 (or endpos
971 ;; Get error now if we don't have a complete sexp after point.
972 (save-excursion (forward-sexp 1)))
973 (save-excursion
974 (setq outer-loop-done nil)
975 (while (if endpos (< (point) endpos)
976 (not outer-loop-done))
977 (setq last-depth next-depth
978 inner-loop-done nil)
979 ;; Parse this line so we can learn the state
980 ;; to indent the next line.
981 ;; This inner loop goes through only once
982 ;; unless a line ends inside a string.
983 (while (and (not inner-loop-done)
984 (not (setq outer-loop-done (eobp))))
985 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
986 nil nil state))
987 (setq next-depth (car state))
988 ;; If the line contains a comment other than the sort
989 ;; that is indented like code,
990 ;; indent it now with indent-for-comment.
991 ;; Comments indented like code are right already.
992 ;; In any case clear the in-comment flag in the state
993 ;; because parse-partial-sexp never sees the newlines.
994 (if (car (nthcdr 4 state))
995 (progn (indent-for-comment)
996 (end-of-line)
997 (setcar (nthcdr 4 state) nil)))
998 ;; If this line ends inside a string,
999 ;; go straight to next line, remaining within the inner loop,
1000 ;; and turn off the \-flag.
1001 (if (car (nthcdr 3 state))
1002 (progn
1003 (forward-line 1)
1004 (setcar (nthcdr 5 state) nil))
1005 (setq inner-loop-done t)))
1006 (and endpos
1007 (<= next-depth 0)
1008 (progn
1009 (setq indent-stack (nconc indent-stack
1010 (make-list (- next-depth) nil))
1011 last-depth (- last-depth next-depth)
1012 next-depth 0)))
1013 (or outer-loop-done endpos
1014 (setq outer-loop-done (<= next-depth 0)))
1015 (if outer-loop-done
1016 (forward-line 1)
1017 (while (> last-depth next-depth)
1018 (setq indent-stack (cdr indent-stack)
1019 last-depth (1- last-depth)))
1020 (while (< last-depth next-depth)
1021 (setq indent-stack (cons nil indent-stack)
1022 last-depth (1+ last-depth)))
1023 ;; Now go to the next line and indent it according
1024 ;; to what we learned from parsing the previous one.
1025 (forward-line 1)
1026 (setq bol (point))
1027 (skip-chars-forward " \t")
1028 ;; But not if the line is blank, or just a comment
1029 ;; (except for double-semi comments; indent them as usual).
1030 (if (or (eobp) (looking-at "\\s<\\|\n"))
1032 (if (and (car indent-stack)
1033 (>= (car indent-stack) 0))
1034 (setq this-indent (car indent-stack))
1035 (let ((val (calculate-lisp-indent
1036 (if (car indent-stack) (- (car indent-stack))
1037 starting-point))))
1038 (if (null val)
1039 (setq this-indent val)
1040 (if (integerp val)
1041 (setcar indent-stack
1042 (setq this-indent val))
1043 (setcar indent-stack (- (car (cdr val))))
1044 (setq this-indent (car val))))))
1045 (if (and this-indent (/= (current-column) this-indent))
1046 (progn (delete-region bol (point))
1047 (indent-to this-indent)))))
1048 (or outer-loop-done
1049 (setq outer-loop-done (= (point) last-point))
1050 (setq last-point (point)))))))
1052 (defun lisp-indent-region (start end)
1053 "Indent every line whose first char is between START and END inclusive."
1054 (save-excursion
1055 (let ((endmark (copy-marker end)))
1056 (goto-char start)
1057 (and (bolp) (not (eolp))
1058 (lisp-indent-line))
1059 (indent-sexp endmark)
1060 (set-marker endmark nil))))
1062 ;;;; Lisp paragraph filling commands.
1064 (defcustom emacs-lisp-docstring-fill-column 65
1065 "Value of `fill-column' to use when filling a docstring.
1066 Any non-integer value means do not use a different value of
1067 `fill-column' when filling docstrings."
1068 :type '(choice (integer)
1069 (const :tag "Use the current `fill-column'" t))
1070 :group 'lisp)
1072 (defun lisp-fill-paragraph (&optional justify)
1073 "Like \\[fill-paragraph], but handle Emacs Lisp comments and docstrings.
1074 If any of the current line is a comment, fill the comment or the
1075 paragraph of it that point is in, preserving the comment's indentation
1076 and initial semicolons."
1077 (interactive "P")
1078 (or (fill-comment-paragraph justify)
1079 ;; Point is on a program line (a line no comment); we are interested
1080 ;; particularly in docstring lines.
1082 ;; We bind `paragraph-start' and `paragraph-separate' temporarily. They
1083 ;; are buffer-local, but we avoid changing them so that they can be set
1084 ;; to make `forward-paragraph' and friends do something the user wants.
1086 ;; `paragraph-start': The `(' in the character alternative and the
1087 ;; left-singlequote plus `(' sequence after the \\| alternative prevent
1088 ;; sexps and backquoted sexps that follow a docstring from being filled
1089 ;; with the docstring. This setting has the consequence of inhibiting
1090 ;; filling many program lines that are not docstrings, which is sensible,
1091 ;; because the user probably asked to fill program lines by accident, or
1092 ;; expecting indentation (perhaps we should try to do indenting in that
1093 ;; case). The `;' and `:' stop the paragraph being filled at following
1094 ;; comment lines and at keywords (e.g., in `defcustom'). Left parens are
1095 ;; escaped to keep font-locking, filling, & paren matching in the source
1096 ;; file happy.
1098 ;; `paragraph-separate': A clever regexp distinguishes the first line of
1099 ;; a docstring and identifies it as a paragraph separator, so that it
1100 ;; won't be filled. (Since the first line of documentation stands alone
1101 ;; in some contexts, filling should not alter the contents the author has
1102 ;; chosen.) Only the first line of a docstring begins with whitespace
1103 ;; and a quotation mark and ends with a period or (rarely) a comma.
1105 ;; The `fill-column' is temporarily bound to
1106 ;; `emacs-lisp-docstring-fill-column' if that value is an integer.
1107 (let ((paragraph-start (concat paragraph-start
1108 "\\|\\s-*\\([\(;:\"]\\|`\(\\)"))
1109 (paragraph-separate
1110 (concat paragraph-separate "\\|\\s-*\".*[,\\.]$"))
1111 (fill-column (if (integerp emacs-lisp-docstring-fill-column)
1112 emacs-lisp-docstring-fill-column
1113 fill-column)))
1114 (fill-paragraph justify))
1115 ;; Never return nil.
1118 (defun indent-code-rigidly (start end arg &optional nochange-regexp)
1119 "Indent all lines of code, starting in the region, sideways by ARG columns.
1120 Does not affect lines starting inside comments or strings, assuming that
1121 the start of the region is not inside them.
1123 Called from a program, takes args START, END, COLUMNS and NOCHANGE-REGEXP.
1124 The last is a regexp which, if matched at the beginning of a line,
1125 means don't indent that line."
1126 (interactive "r\np")
1127 (let (state)
1128 (save-excursion
1129 (goto-char end)
1130 (setq end (point-marker))
1131 (goto-char start)
1132 (or (bolp)
1133 (setq state (parse-partial-sexp (point)
1134 (progn
1135 (forward-line 1) (point))
1136 nil nil state)))
1137 (while (< (point) end)
1138 (or (car (nthcdr 3 state))
1139 (and nochange-regexp
1140 (looking-at nochange-regexp))
1141 ;; If line does not start in string, indent it
1142 (let ((indent (current-indentation)))
1143 (delete-region (point) (progn (skip-chars-forward " \t") (point)))
1144 (or (eolp)
1145 (indent-to (max 0 (+ indent arg)) 0))))
1146 (setq state (parse-partial-sexp (point)
1147 (progn
1148 (forward-line 1) (point))
1149 nil nil state))))))
1151 (provide 'lisp-mode)
1153 ;;; lisp-mode.el ends here