Mercurial > emacs
comparison lisp/emacs-lisp/lisp-mode.el @ 41512:4f4835967793
(lisp-mode-variables): Set syntax-begin-function.
(lisp-interaction-mode-abbrev-table): Defvar to its correct value.
(lisp-interaction-mode): Don't set local-abbrev-table any more.
(lisp-mode-auto-fill): Use syntax-ppss and obey
comment-auto-fill-only-comments.
(lisp-fill-paragraph): Use syntax-ppss.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 25 Nov 2001 21:47:40 +0000 |
parents | aeb0c4a140d2 |
children | 1e0988cac637 |
comparison
equal
deleted
inserted
replaced
41511:19496cafe865 | 41512:4f4835967793 |
---|---|
193 (setq comment-indent-function 'lisp-comment-indent) | 193 (setq comment-indent-function 'lisp-comment-indent) |
194 (make-local-variable 'imenu-generic-expression) | 194 (make-local-variable 'imenu-generic-expression) |
195 (setq imenu-generic-expression lisp-imenu-generic-expression) | 195 (setq imenu-generic-expression lisp-imenu-generic-expression) |
196 (make-local-variable 'multibyte-syntax-as-symbol) | 196 (make-local-variable 'multibyte-syntax-as-symbol) |
197 (setq multibyte-syntax-as-symbol t) | 197 (setq multibyte-syntax-as-symbol t) |
198 (set (make-local-variable 'syntax-begin-function) 'beginning-of-defun) | |
198 (setq font-lock-defaults | 199 (setq font-lock-defaults |
199 '((lisp-font-lock-keywords | 200 '((lisp-font-lock-keywords |
200 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) | 201 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) |
201 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun | 202 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun |
202 (font-lock-mark-block-function . mark-defun) | 203 (font-lock-mark-block-function . mark-defun) |
364 (define-key map "\n" 'eval-print-last-sexp) | 365 (define-key map "\n" 'eval-print-last-sexp) |
365 map) | 366 map) |
366 "Keymap for Lisp Interaction mode. | 367 "Keymap for Lisp Interaction mode. |
367 All commands in `lisp-mode-shared-map' are inherited by this map.") | 368 All commands in `lisp-mode-shared-map' are inherited by this map.") |
368 | 369 |
370 (defvar lisp-interaction-mode-abbrev-table lisp-mode-abbrev-table) | |
369 (define-derived-mode lisp-interaction-mode emacs-lisp-mode "Lisp Interaction" | 371 (define-derived-mode lisp-interaction-mode emacs-lisp-mode "Lisp Interaction" |
370 "Major mode for typing and evaluating Lisp forms. | 372 "Major mode for typing and evaluating Lisp forms. |
371 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression | 373 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression |
372 before point, and prints its value into the buffer, advancing point. | 374 before point, and prints its value into the buffer, advancing point. |
373 Note that printing is controlled by `eval-expression-print-length' | 375 Note that printing is controlled by `eval-expression-print-length' |
377 Delete converts tabs to spaces as it moves back. | 379 Delete converts tabs to spaces as it moves back. |
378 Paragraphs are separated only by blank lines. | 380 Paragraphs are separated only by blank lines. |
379 Semicolons start comments. | 381 Semicolons start comments. |
380 \\{lisp-interaction-mode-map} | 382 \\{lisp-interaction-mode-map} |
381 Entry to this mode calls the value of `lisp-interaction-mode-hook' | 383 Entry to this mode calls the value of `lisp-interaction-mode-hook' |
382 if that value is non-nil." | 384 if that value is non-nil.") |
383 (setq local-abbrev-table lisp-mode-abbrev-table)) | |
384 | 385 |
385 (defun eval-print-last-sexp () | 386 (defun eval-print-last-sexp () |
386 "Evaluate sexp before point; print value into current buffer. | 387 "Evaluate sexp before point; print value into current buffer. |
387 | 388 |
388 Note that printing the result is controlled by the variables | 389 Note that printing the result is controlled by the variables |
636 ;; Note: `newcomment' gets it right in 99% of the cases if you're using | 637 ;; Note: `newcomment' gets it right in 99% of the cases if you're using |
637 ;; font-lock, anyway, so we could get rid of it. -stef | 638 ;; font-lock, anyway, so we could get rid of it. -stef |
638 (defun lisp-mode-auto-fill () | 639 (defun lisp-mode-auto-fill () |
639 (if (> (current-column) (current-fill-column)) | 640 (if (> (current-column) (current-fill-column)) |
640 (if (save-excursion | 641 (if (save-excursion |
641 (nth 4 (parse-partial-sexp (save-excursion | 642 (nth 4 (syntax-ppss (point)))) |
642 (beginning-of-defun) | |
643 (point)) | |
644 (point)))) | |
645 (do-auto-fill) | 643 (do-auto-fill) |
646 (let ((comment-start nil) (comment-start-skip nil)) | 644 (unless (and (boundp 'comment-auto-fill-only-comments) |
647 (do-auto-fill))))) | 645 comment-auto-fill-only-comments) |
646 (let ((comment-start nil) (comment-start-skip nil)) | |
647 (do-auto-fill)))))) | |
648 | 648 |
649 (defvar lisp-indent-offset nil | 649 (defvar lisp-indent-offset nil |
650 "If non-nil, indent second line of expressions that many more columns.") | 650 "If non-nil, indent second line of expressions that many more columns.") |
651 (defvar lisp-indent-function 'lisp-indent-function) | 651 (defvar lisp-indent-function 'lisp-indent-function) |
652 | 652 |
1077 (match-end 0)))) | 1077 (match-end 0)))) |
1078 | 1078 |
1079 ;; A line with some code, followed by a comment? Remember that the | 1079 ;; A line with some code, followed by a comment? Remember that the |
1080 ;; semi which starts the comment shouldn't be part of a string or | 1080 ;; semi which starts the comment shouldn't be part of a string or |
1081 ;; character. | 1081 ;; character. |
1082 ((condition-case nil | 1082 ((let ((state (syntax-ppss (line-end-position)))) |
1083 (save-restriction | 1083 (when (nth 4 state) |
1084 (narrow-to-region (point-min) | 1084 (goto-char (nth 8 state)) |
1085 (save-excursion (end-of-line) (point))) | 1085 (looking-at ";+[\t ]*"))) |
1086 (while (not (looking-at ";\\|$")) | |
1087 (skip-chars-forward "^;\n\"\\\\?") | |
1088 (cond | |
1089 ((eq (char-after (point)) ?\\) (forward-char 2)) | |
1090 ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) | |
1091 (looking-at ";+[\t ]*")) | |
1092 (error nil)) | |
1093 (setq has-comment t has-code-and-comment t) | 1086 (setq has-comment t has-code-and-comment t) |
1094 (setq comment-fill-prefix | 1087 (setq comment-fill-prefix |
1095 (concat (make-string (/ (current-column) tab-width) ?\t) | 1088 (concat (make-string (/ (current-column) tab-width) ?\t) |
1096 (make-string (% (current-column) tab-width) ?\ ) | 1089 (make-string (% (current-column) tab-width) ?\ ) |
1097 (buffer-substring (match-beginning 0) (match-end 0))))))) | 1090 (buffer-substring (match-beginning 0) (match-end 0))))))) |