comparison lisp/emacs-lisp/lisp-mode.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents af0933fdc21a
children 4c90ffeb71c5
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
1 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands 1 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands
2 2
3 ;; Copyright (C) 1985, 1986, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985,86,1999,2000,01,03,2004 Free Software Foundation, Inc.
4 4
5 ;; Maintainer: FSF 5 ;; Maintainer: FSF
6 ;; Keywords: lisp, languages 6 ;; Keywords: lisp, languages
7 7
8 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
171 ;; Adaptive fill mode gets in the way of auto-fill, 171 ;; Adaptive fill mode gets in the way of auto-fill,
172 ;; and should make no difference for explicit fill 172 ;; and should make no difference for explicit fill
173 ;; because lisp-fill-paragraph should do the job. 173 ;; because lisp-fill-paragraph should do the job.
174 ;; I believe that newcomment's auto-fill code properly deals with it -stef 174 ;; I believe that newcomment's auto-fill code properly deals with it -stef
175 ;;(set (make-local-variable 'adaptive-fill-mode) nil) 175 ;;(set (make-local-variable 'adaptive-fill-mode) nil)
176 (make-local-variable 'normal-auto-fill-function)
177 (setq normal-auto-fill-function 'lisp-mode-auto-fill)
178 (make-local-variable 'indent-line-function) 176 (make-local-variable 'indent-line-function)
179 (setq indent-line-function 'lisp-indent-line) 177 (setq indent-line-function 'lisp-indent-line)
180 (make-local-variable 'indent-region-function) 178 (make-local-variable 'indent-region-function)
181 (setq indent-region-function 'lisp-indent-region) 179 (setq indent-region-function 'lisp-indent-region)
182 (make-local-variable 'parse-sexp-ignore-comments) 180 (make-local-variable 'parse-sexp-ignore-comments)
183 (setq parse-sexp-ignore-comments t) 181 (setq parse-sexp-ignore-comments t)
184 (make-local-variable 'outline-regexp) 182 (make-local-variable 'outline-regexp)
185 (setq outline-regexp ";;;;* \\|(") 183 (setq outline-regexp ";;;;* [^ \t\n]\\|(")
186 (make-local-variable 'outline-level) 184 (make-local-variable 'outline-level)
187 (setq outline-level 'lisp-outline-level) 185 (setq outline-level 'lisp-outline-level)
188 (make-local-variable 'comment-start) 186 (make-local-variable 'comment-start)
189 (setq comment-start ";") 187 (setq comment-start ";")
190 (make-local-variable 'comment-start-skip) 188 (make-local-variable 'comment-start-skip)
193 (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *") 191 (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
194 (make-local-variable 'comment-add) 192 (make-local-variable 'comment-add)
195 (setq comment-add 1) ;default to `;;' in comment-region 193 (setq comment-add 1) ;default to `;;' in comment-region
196 (make-local-variable 'comment-column) 194 (make-local-variable 'comment-column)
197 (setq comment-column 40) 195 (setq comment-column 40)
198 (make-local-variable 'comment-indent-function) 196 ;; Don't get confused by `;' in doc strings when paragraph-filling.
199 (setq comment-indent-function 'lisp-comment-indent) 197 (set (make-local-variable 'comment-use-global-state) t)
200 (make-local-variable 'imenu-generic-expression) 198 (make-local-variable 'imenu-generic-expression)
201 (setq imenu-generic-expression lisp-imenu-generic-expression) 199 (setq imenu-generic-expression lisp-imenu-generic-expression)
202 (make-local-variable 'multibyte-syntax-as-symbol) 200 (make-local-variable 'multibyte-syntax-as-symbol)
203 (setq multibyte-syntax-as-symbol t) 201 (setq multibyte-syntax-as-symbol t)
204 (set (make-local-variable 'syntax-begin-function) 'beginning-of-defun) 202 (set (make-local-variable 'syntax-begin-function) 'beginning-of-defun)
205 (setq font-lock-defaults 203 (setq font-lock-defaults
206 '((lisp-font-lock-keywords 204 '((lisp-font-lock-keywords
207 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) 205 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
208 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun 206 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) nil
209 (font-lock-mark-block-function . mark-defun) 207 (font-lock-mark-block-function . mark-defun)
210 (font-lock-syntactic-face-function 208 (font-lock-syntactic-face-function
211 . lisp-font-lock-syntactic-face-function)))) 209 . lisp-font-lock-syntactic-face-function))))
212 210
213 (defun lisp-outline-level () 211 (defun lisp-outline-level ()
214 "Lisp mode `outline-level' function." 212 "Lisp mode `outline-level' function."
215 (if (looking-at "(") 213 (if (looking-at "(\\|;;;###autoload")
216 1000 214 1000
217 (looking-at outline-regexp) 215 (looking-at outline-regexp)
218 (- (match-end 0) (match-beginning 0)))) 216 (- (match-end 0) (match-beginning 0))))
219 217
220 218
356 (setq font-lock-keywords-case-fold-search t) 354 (setq font-lock-keywords-case-fold-search t)
357 (setq imenu-case-fold-search t) 355 (setq imenu-case-fold-search t)
358 (set-syntax-table lisp-mode-syntax-table) 356 (set-syntax-table lisp-mode-syntax-table)
359 (run-mode-hooks 'lisp-mode-hook)) 357 (run-mode-hooks 'lisp-mode-hook))
360 358
359 ;; Used in old LispM code.
360 (defalias 'common-lisp-mode 'lisp-mode)
361
361 ;; This will do unless inf-lisp.el is loaded. 362 ;; This will do unless inf-lisp.el is loaded.
362 (defun lisp-eval-defun (&optional and-go) 363 (defun lisp-eval-defun (&optional and-go)
363 "Send the current defun to the Lisp process made by \\[run-lisp]." 364 "Send the current defun to the Lisp process made by \\[run-lisp]."
364 (interactive) 365 (interactive)
365 (error "Process lisp does not exist")) 366 (error "Process lisp does not exist"))
446 (defun prin1-char (char) 447 (defun prin1-char (char)
447 "Return a string representing CHAR as a character rather than as an integer. 448 "Return a string representing CHAR as a character rather than as an integer.
448 If CHAR is not a character, return nil." 449 If CHAR is not a character, return nil."
449 (and (integerp char) 450 (and (integerp char)
450 (characterp (event-basic-type char)) 451 (characterp (event-basic-type char))
451 (concat 452 (let ((c (event-basic-type char)))
452 "?" 453 (concat
453 (mapconcat 454 "?"
454 (lambda (modif) 455 (mapconcat
455 (cond ((eq modif 'super) "\\s-") 456 (lambda (modif)
456 (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-)))) 457 (cond ((eq modif 'super) "\\s-")
457 (event-modifiers char) "") 458 (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-))))
458 (string (event-basic-type char))))) 459 (event-modifiers char) "")
460 (cond
461 ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c))
462 ((eq c 127) "\\C-?")
463 (t (string c)))))))
459 464
460 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) 465 (defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
461 "Evaluate sexp before point; print value in minibuffer. 466 "Evaluate sexp before point; print value in minibuffer.
462 With argument, print output into current buffer." 467 With argument, print output into current buffer."
463 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) 468 (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t)))
510 (list 'lambda 515 (list 'lambda
511 '(&rest args) 516 '(&rest args)
512 expr 517 expr
513 'args))))) 518 'args)))))
514 expr))))))) 519 expr)))))))
515 (let ((unabbreviated (let ((print-length nil) (print-level nil)) 520 (eval-last-sexp-print-value value))))
516 (prin1-to-string value))) 521
517 (print-length eval-expression-print-length) 522 (defun eval-last-sexp-print-value (value)
518 (print-level eval-expression-print-level) 523 (let ((unabbreviated (let ((print-length nil) (print-level nil))
519 (char-string (prin1-char value)) 524 (prin1-to-string value)))
520 (beg (point)) 525 (print-length eval-expression-print-length)
521 end) 526 (print-level eval-expression-print-level)
522 (prog1 527 (char-string (prin1-char value))
523 (prin1 value) 528 (beg (point))
524 (if (and (eq standard-output t) char-string) 529 end)
525 (princ (concat " = " char-string))) 530 (prog1
526 (setq end (point)) 531 (prin1 value)
527 (when (and (bufferp standard-output) 532 (if (and (eq standard-output t) char-string)
528 (or (not (null print-length)) 533 (princ (concat " = " char-string)))
529 (not (null print-level))) 534 (setq end (point))
530 (not (string= unabbreviated 535 (when (and (bufferp standard-output)
531 (buffer-substring-no-properties beg end)))) 536 (or (not (null print-length))
532 (last-sexp-setup-props beg end value 537 (not (null print-level)))
533 unabbreviated 538 (not (string= unabbreviated
534 (buffer-substring-no-properties beg end)) 539 (buffer-substring-no-properties beg end))))
535 )))))) 540 (last-sexp-setup-props beg end value
541 unabbreviated
542 (buffer-substring-no-properties beg end))
543 ))))
536 544
537 545
538 (defun eval-last-sexp (eval-last-sexp-arg-internal) 546 (defun eval-last-sexp (eval-last-sexp-arg-internal)
539 "Evaluate sexp before point; print value in minibuffer. 547 "Evaluate sexp before point; print value in minibuffer.
540 Interactively, with prefix argument, print output into current buffer." 548 Interactively, with prefix argument, print output into current buffer."
661 comment-column)))) 669 comment-column))))
662 670
663 ;; This function just forces a more costly detection of comments (using 671 ;; This function just forces a more costly detection of comments (using
664 ;; parse-partial-sexp from beginning-of-defun). I.e. It avoids the problem of 672 ;; parse-partial-sexp from beginning-of-defun). I.e. It avoids the problem of
665 ;; taking a `;' inside a string started on another line for a comment starter. 673 ;; taking a `;' inside a string started on another line for a comment starter.
666 ;; Note: `newcomment' gets it right in 99% of the cases if you're using 674 ;; Note: `newcomment' gets it right now since we set comment-use-global-state
667 ;; font-lock, anyway, so we could get rid of it. -stef 675 ;; so we could get rid of it. -stef
668 (defun lisp-mode-auto-fill () 676 (defun lisp-mode-auto-fill ()
669 (if (> (current-column) (current-fill-column)) 677 (if (> (current-column) (current-fill-column))
670 (if (save-excursion 678 (if (save-excursion
671 (nth 4 (syntax-ppss (point)))) 679 (nth 4 (syntax-ppss (point))))
672 (do-auto-fill) 680 (do-auto-fill)
1165 (forward-line 1) (point)) 1173 (forward-line 1) (point))
1166 nil nil state)))))) 1174 nil nil state))))))
1167 1175
1168 (provide 'lisp-mode) 1176 (provide 'lisp-mode)
1169 1177
1178 ;;; arch-tag: 414c7f93-c245-4b77-8ed5-ed05ef7ff1bf
1170 ;;; lisp-mode.el ends here 1179 ;;; lisp-mode.el ends here