-;; Lisp mode, and its idiosyncratic commands.
+;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands.
+
;; Copyright (C) 1985 Free Software Foundation, Inc.
+;; Maintainer: FSF
+;; Keywords: lisp, languages
+
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
(defvar lisp-mode-syntax-table nil "")
(defvar emacs-lisp-mode-syntax-table nil "")
(defvar lisp-mode-abbrev-table nil "")
(modify-syntax-entry ?\[ "(] " emacs-lisp-mode-syntax-table)
(modify-syntax-entry ?\] ")[ " emacs-lisp-mode-syntax-table)))
+(if (not lisp-mode-syntax-table)
+ (progn (setq lisp-mode-syntax-table
+ (copy-syntax-table emacs-lisp-mode-syntax-table))
+ (modify-syntax-entry ?\| "\" " lisp-mode-syntax-table)
+ (modify-syntax-entry ?\[ "_ " lisp-mode-syntax-table)
+ (modify-syntax-entry ?\] "_ " lisp-mode-syntax-table)))
+
(define-abbrev-table 'lisp-mode-abbrev-table ())
(defun lisp-mode-variables (lisp-syntax)
(cond (lisp-syntax
- (if (not lisp-mode-syntax-table)
- (progn (setq lisp-mode-syntax-table
- (copy-syntax-table emacs-lisp-mode-syntax-table))
- (modify-syntax-entry ?\| "\" "
- lisp-mode-syntax-table)
- (modify-syntax-entry ?\[ "_ "
- lisp-mode-syntax-table)
- (modify-syntax-entry ?\] "_ "
- lisp-mode-syntax-table)))
(set-syntax-table lisp-mode-syntax-table)))
(setq local-abbrev-table lisp-mode-abbrev-table)
(make-local-variable 'paragraph-start)
()
(setq emacs-lisp-mode-map
(nconc (make-sparse-keymap) shared-lisp-mode-map))
+ (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol)
(define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun))
(defun emacs-lisp-mode ()
(setq lisp-interaction-mode-map
(nconc (make-sparse-keymap) shared-lisp-mode-map))
(define-key lisp-interaction-mode-map "\e\C-x" 'eval-defun)
+ (define-key lisp-interaction-mode-map "\e\t" 'lisp-complete-symbol)
(define-key lisp-interaction-mode-map "\n" 'eval-print-last-sexp))
(defun lisp-interaction-mode ()
(defun eval-print-last-sexp ()
"Evaluate sexp before point; print value into current buffer."
(interactive)
- (newline)
- (eval-last-sexp t)
- (newline))
+ (let ((standard-output (current-buffer)))
+ (terpri)
+ (eval-last-sexp t)
+ (terpri)))
\f
(defun eval-last-sexp (arg)
"Evaluate sexp before point; print value in minibuffer.
With argument, print output into current buffer."
(interactive "P")
- (let ((standard-output (if arg (current-buffer) t)))
+ (let ((standard-output (if arg (current-buffer) t))
+ (opoint (point)))
(prin1 (let ((stab (syntax-table)))
(eval (unwind-protect
(save-excursion
(set-syntax-table emacs-lisp-mode-syntax-table)
(forward-sexp -1)
- (read (current-buffer)))
+ (save-restriction
+ (narrow-to-region (point-min) opoint)
+ (read (current-buffer))))
(set-syntax-table stab)))))))
(defun eval-defun (arg)
(skip-chars-forward " \t")
(if (looking-at "\\s<\\s<\\s<")
;; Don't alter indentation of a ;;; comment line.
- nil
+ (goto-char (- (point-max) pos))
(if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<")))
;; Single-semicolon comment lines should be indented
;; as comment lines, not as code.
(put 'save-excursion 'lisp-indent-function 0)
(put 'save-window-excursion 'lisp-indent-function 0)
(put 'save-restriction 'lisp-indent-function 0)
+(put 'save-match-data 'lisp-indent-function 0)
(put 'let 'lisp-indent-function 1)
(put 'let* 'lisp-indent-function 1)
(put 'while 'lisp-indent-function 1)
If optional arg ENDPOS is given, indent each line, stopping when
ENDPOS is encountered."
(interactive)
- (let ((indent-stack (list nil)) (next-depth 0) last-depth bol
- outer-loop-done inner-loop-done state this-indent
- (last-point (point)))
+ (let ((indent-stack (list nil))
+ (next-depth 0)
+ (starting-point (point))
+ (last-point (point))
+ last-depth bol outer-loop-done inner-loop-done state this-indent)
;; Get error now if we don't have a complete sexp after point.
(save-excursion (forward-sexp 1))
(save-excursion
(setcar (nthcdr 5 state) nil))
(setq inner-loop-done t)))
(and endpos
- (while (<= next-depth 0)
- (setq indent-stack (append indent-stack (list nil)))
- (setq next-depth (1+ next-depth))
- (setq last-depth (1+ last-depth))))
+ (<= next-depth 0)
+ (progn
+ (setq indent-stack (append indent-stack
+ (make-list (- next-depth) nil))
+ last-depth (- last-depth next-depth)
+ next-depth 0)))
(or outer-loop-done
(setq outer-loop-done (<= next-depth 0)))
(if outer-loop-done
(setq this-indent (car indent-stack))
(let ((val (calculate-lisp-indent
(if (car indent-stack) (- (car indent-stack))
- last-point))))
+ starting-point))))
(if (integerp val)
(setcar indent-stack
(setq this-indent val))
(progn
(forward-line 1) (point))
nil nil state))))))
+
+(provide 'lisp-mode)
+
+;;; lisp-mode.el ends here