Commit d7f519ed authored by Gerd Moellmann's avatar Gerd Moellmann

(lisp-imenu-generic-expression): Use regexp-opt.

(doc-string-elt): Set symbol's prop.  Copied from autoload.el.
(lisp-font-lock-syntactic-face-function): New function.
(lisp-mode-variables): Use it.  Make arg optional.
(emacs-lisp-mode): Don't pass an arg to lisp-mode-variables.
(lisp-mode): Don't pass an arg to lisp-mode-variables.
Set comment-start-skip.
parent 3d1b88f6
......@@ -83,19 +83,78 @@
(defvar lisp-imenu-generic-expression
(list
(list nil
(purecopy "^\\s-*(def\\(un\\*?\\|subst\\|macro\\|advice\\|\
ine-skeleton\\|ine-minor-mode\\)\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)") 2)
(purecopy (concat "^\\s-*("
(eval-when-compile
(regexp-opt
'("defun" "defun*" "defsubst" "defmacro"
"defadvice" "define-skeleton"
"define-minor-mode" "define-derived-mode"
"define-compiler-macro" "define-modify-macro"
"defsetf" "define-setf-expander"
"define-method-combination"
"defgeneric" "defmethod") t)
"\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)")))
2)
(list (purecopy "Variables")
(purecopy "^\\s-*(def\\(var\\|const\\|custom\\)\\s-+\
\\(\\sw\\(\\sw\\|\\s_\\)+\\)") 2)
(purecopy (concat "^\\s-*("
(eval-when-compile
(regexp-opt
'("defvar" "defconst" "defconstant" "defcustom"
"defparameter" "define-symbol-macro") t)
"\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)")))
2)
(list (purecopy "Types")
(purecopy "^\\s-*(def\\(group\\|type\\|struct\\|class\\|\
ine-condition\\|ine-widget\\|face\\)\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)")
(purecopy (concat "^\\s-*("
(eval-when-compile
(regexp-opt
'("defgroup" "deftype" "defstruct" "defclass"
"define-condition" "define-widget" "defface"
"defpackage") t)
"\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)")))
2))
"Imenu generic expression for Lisp mode. See `imenu-generic-expression'.")
(defun lisp-mode-variables (lisp-syntax)
;; This was originally in autoload.el and is still used there.
(put 'autoload 'doc-string-elt 3)
(put 'defun 'doc-string-elt 3)
(put 'defun* 'doc-string-elt 3)
(put 'defvar 'doc-string-elt 3)
(put 'defcustom 'doc-string-elt 3)
(put 'defconst 'doc-string-elt 3)
(put 'defmacro 'doc-string-elt 3)
(put 'defsubst 'doc-string-elt 3)
(put 'define-skeleton 'doc-string-elt 2)
(put 'define-derived-mode 'doc-string-elt 4)
(put 'easy-mmode-define-minor-mode 'doc-string-elt 2)
(put 'define-minor-mode 'doc-string-elt 2)
(put 'define-generic-mode 'doc-string-elt 7)
;; define-global-mode has no explicit docstring.
(put 'easy-mmode-define-global-mode 'doc-string-elt 0)
(defun lisp-font-lock-syntactic-face-function (state)
(if (nth 3 state)
(if (and (eq (nth 0 state) 1)
;; This might be a docstring.
(save-excursion
(let ((n 0))
(goto-char (nth 8 state))
(condition-case nil
(while (progn (backward-sexp 1) (setq n (1+ n))))
(scan-error nil))
(when (> n 0)
(let ((sym (intern-soft
(buffer-substring
(point) (progn (forward-sexp 1) (point))))))
(eq n (or (get sym 'doc-string-elt) 3)))))))
font-lock-doc-face
font-lock-string-face)
font-lock-comment-face))
;; The LISP-SYNTAX argument is used by code in inf-lisp.el and is
;; (uselessly) passed from pp.el, chistory.el, gnus-kill.el and score-mode.el
(defun lisp-mode-variables (&optional lisp-syntax)
(cond (lisp-syntax
(set-syntax-table lisp-mode-syntax-table)))
(setq local-abbrev-table lisp-mode-abbrev-table)
......@@ -144,7 +203,9 @@ ine-condition\\|ine-widget\\|face\\)\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)")
'((lisp-font-lock-keywords
lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
(font-lock-mark-block-function . mark-defun))))
(font-lock-mark-block-function . mark-defun)
(font-lock-syntactic-face-function
. lisp-font-lock-syntactic-face-function))))
(defun lisp-outline-level ()
"Lisp mode `outline-level' function."
......@@ -248,7 +309,7 @@ Blank lines separate paragraphs. Semicolons start comments.
\\{emacs-lisp-mode-map}
Entry to this mode calls the value of `emacs-lisp-mode-hook'
if that value is non-nil."
(lisp-mode-variables nil)
(lisp-mode-variables)
(setq imenu-case-fold-search nil))
(defvar lisp-mode-map
......@@ -271,9 +332,10 @@ or to switch back to an existing one.
Entry to this mode calls the value of `lisp-mode-hook'
if that value is non-nil."
(lisp-mode-variables t)
(make-local-variable 'font-lock-keywords-case-fold-search)
(setq font-lock-keywords-case-fold-search t)
(lisp-mode-variables)
(set (make-local-variable 'comment-start-skip)
"\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
(set (make-local-variable 'font-lock-keywords-case-fold-search) t)
(setq imenu-case-fold-search t))
;; This will do unless inf-lisp.el is loaded.
......@@ -573,10 +635,9 @@ which see."
With argument, indent any additional lines of the same expression
rigidly along with this one."
(interactive "P")
(let ((indent (calculate-lisp-indent)) shift-amt beg end
(pos (- (point-max) (point))))
(beginning-of-line)
(setq beg (point))
(let ((indent (calculate-lisp-indent)) shift-amt end
(pos (- (point-max) (point)))
(beg (progn (beginning-of-line) (point))))
(skip-chars-forward " \t")
(if (or (null indent) (looking-at "\\s<\\s<\\s<"))
;; Don't alter indentation of a ;;; comment line
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment