]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/lisp-mode.el
Merge from emacs-24; up to 2014-04-25T10:35:01Z!michael.albinus@gmx.de
[gnu-emacs] / lisp / emacs-lisp / lisp-mode.el
index b7bd33f628fe1d9b68ea22e029af973793d1627e..7e00d0b2cf96b258b8868d65304f74b56c8d1f8c 100644 (file)
@@ -1,8 +1,8 @@
 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1999-2014 Free Software Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: lisp, languages
 ;; Package: emacs
 
@@ -74,7 +74,7 @@ It has `lisp-mode-abbrev-table' as its parent."
     (modify-syntax-entry ?` "'   " table)
     (modify-syntax-entry ?' "'   " table)
     (modify-syntax-entry ?, "'   " table)
-    (modify-syntax-entry ?@ "'   " table)
+    (modify-syntax-entry ?@ "_ p" table)
     ;; Used to be singlequote; changed for flonums.
     (modify-syntax-entry ?. "_   " table)
     (modify-syntax-entry ?# "'   " table)
@@ -104,7 +104,8 @@ It has `lisp-mode-abbrev-table' as its parent."
                             (regexp-opt
                              '("defun" "defun*" "defsubst" "defmacro"
                                "defadvice" "define-skeleton"
-                               "define-minor-mode" "define-global-minor-mode"
+                               "define-compilation-mode" "define-minor-mode"
+                               "define-global-minor-mode"
                                "define-globalized-minor-mode"
                                "define-derived-mode" "define-generic-mode"
                                "define-compiler-macro" "define-modify-macro"
@@ -156,6 +157,23 @@ It has `lisp-mode-abbrev-table' as its parent."
 
 ;;;; Font-lock support.
 
+(defun lisp--match-hidden-arg (limit)
+  (let ((res nil))
+    (while
+        (let ((ppss (parse-partial-sexp (line-beginning-position)
+                                        (line-end-position)
+                                        -1)))
+          (if (or (>= (car ppss) 0)
+                  (looking-at "[]) \t]*\\(;\\|$\\)"))
+              (progn
+                (forward-line 1)
+                (< (point) limit))
+            (looking-at ".*")           ;Set the match-data.
+           (forward-line 1)
+            (setq res (point))
+            nil)))
+    res))
+
 (pcase-let
     ((`(,vdefs ,tdefs
         ,el-defs-re ,cl-defs-re
@@ -347,6 +365,9 @@ It has `lisp-mode-abbrev-table' as its parent."
        ;; and that they get the wrong color.
        ;; ;; CL `with-' and `do-' constructs
        ;;("(\\(\\(do-\\|with-\\)\\(\\s_\\|\\w\\)*\\)" 1 font-lock-keyword-face)
+       (lisp--match-hidden-arg
+        (0 '(face font-lock-warning-face
+             help-echo "Hidden behind deeper element; move to another line?")))
        ))
     "Gaudy level highlighting for Emacs Lisp mode.")
 
@@ -377,6 +398,9 @@ It has `lisp-mode-abbrev-table' as its parent."
        ;; and that they get the wrong color.
        ;; ;; CL `with-' and `do-' constructs
        ;;("(\\(\\(do-\\|with-\\)\\(\\s_\\|\\w\\)*\\)" 1 font-lock-keyword-face)
+       (lisp--match-hidden-arg
+        (0 '(face font-lock-warning-face
+             help-echo "Hidden behind deeper element; move to another line?")))
        ))
     "Gaudy level highlighting for Lisp modes."))
 
@@ -449,18 +473,13 @@ font-lock keywords will not be case sensitive."
   (setq-local outline-level 'lisp-outline-level)
   (setq-local add-log-current-defun-function #'lisp-current-defun-name)
   (setq-local comment-start ";")
-  ;; Look within the line for a ; following an even number of backslashes
-  ;; after either a non-backslash or the line beginning.
-  (setq-local comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
-  ;; Font lock mode uses this only when it KNOWS a comment is starting.
-  (setq-local font-lock-comment-start-skip ";+ *")
+  (setq-local comment-start-skip ";+ *")
   (setq-local comment-add 1)           ;default to `;;' in comment-region
   (setq-local comment-column 40)
-  ;; Don't get confused by `;' in doc strings when paragraph-filling.
-  (setq-local comment-use-global-state t)
+  (setq-local comment-use-syntax t)
   (setq-local imenu-generic-expression lisp-imenu-generic-expression)
   (setq-local multibyte-syntax-as-symbol t)
-  (setq-local syntax-begin-function 'beginning-of-defun)
+  ;; (setq-local syntax-begin-function 'beginning-of-defun)  ;;Bug#16247.
   (setq font-lock-defaults
        `(,(if elisp '(lisp-el-font-lock-keywords
                        lisp-el-font-lock-keywords-1
@@ -470,9 +489,15 @@ font-lock keywords will not be case sensitive."
                lisp-cl-font-lock-keywords-2))
          nil ,keywords-case-insensitive nil nil
          (font-lock-mark-block-function . mark-defun)
+          (font-lock-extra-managed-props help-echo)
          (font-lock-syntactic-face-function
           . lisp-font-lock-syntactic-face-function)))
-  (setq-local prettify-symbols-alist lisp--prettify-symbols-alist))
+  (setq-local prettify-symbols-alist lisp--prettify-symbols-alist)
+  (when elisp
+    (setq-local electric-pair-text-pairs
+                (cons '(?\` . ?\') electric-pair-text-pairs)))
+  (setq-local electric-pair-skip-whitespace 'chomp)
+  (setq-local electric-pair-open-newline-between-pairs nil))
 
 (defun lisp-outline-level ()
   "Lisp mode `outline-level' function."
@@ -675,7 +700,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map.")
 
 (defcustom emacs-lisp-mode-hook nil
   "Hook run when entering Emacs Lisp mode."
-  :options '(turn-on-eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
+  :options '(eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
   :type 'hook
   :group 'lisp)
 
@@ -687,7 +712,7 @@ All commands in `lisp-mode-shared-map' are inherited by this map.")
 
 (defcustom lisp-interaction-mode-hook nil
   "Hook run when entering Lisp Interaction mode."
-  :options '(turn-on-eldoc-mode)
+  :options '(eldoc-mode)
   :type 'hook
   :group 'lisp)
 
@@ -861,14 +886,15 @@ Semicolons start comments.
 (defun eval-print-last-sexp (&optional eval-last-sexp-arg-internal)
   "Evaluate sexp before point; print value into current buffer.
 
-If `eval-expression-debug-on-error' is non-nil, which is the default,
-this command arranges for all errors to enter the debugger.
+Normally, this function truncates long output according to the value
+of the variables `eval-expression-print-length' and
+`eval-expression-print-level'.  With a prefix argument of zero,
+however, there is no such truncation.  Such a prefix argument
+also causes integers to be printed in several additional formats
+\(octal, hexadecimal, and character).
 
-Note that printing the result is controlled by the variables
-`eval-expression-print-length' and `eval-expression-print-level',
-which see.  With a zero prefix arg, print output with no limit
-on the length and level of lists, and include additional formats
-for integers (octal, hexadecimal, and character)."
+If `eval-expression-debug-on-error' is non-nil, which is the default,
+this command arranges for all errors to enter the debugger."
   (interactive "P")
   (let ((standard-output (current-buffer)))
     (terpri)
@@ -1078,10 +1104,12 @@ POS specifies the starting position where EXP was found and defaults to point."
 (defun eval-last-sexp (eval-last-sexp-arg-internal)
   "Evaluate sexp before point; print value in the echo area.
 Interactively, with prefix argument, print output into current buffer.
-Truncates long output according to the value of the variables
-`eval-expression-print-length' and `eval-expression-print-level'.
-With a zero prefix arg, print output with no limit on the length
-and level of lists, and include additional formats for integers
+
+Normally, this function truncates long output according to the value
+of the variables `eval-expression-print-length' and
+`eval-expression-print-level'.  With a prefix argument of zero,
+however, there is no such truncation.  Such a prefix argument
+also causes integers to be printed in several additional formats
 \(octal, hexadecimal, and character).
 
 If `eval-expression-debug-on-error' is non-nil, which is the default,