From 59fd76c178ada8a8b3eb5e3e00609001e9f0195f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 15 Apr 2015 16:39:18 -0400 Subject: * lisp/emacs-lisp/lisp-mode.el (lisp--el-non-funcall-position-p): Avoid pathological slowdown at top-level in large file. --- lisp/emacs-lisp/lisp-mode.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 4c9a39fe174..45d5a0b410c 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -181,22 +181,23 @@ nil))) res)) -(defun lisp--el-non-funcall-position-p (&optional pos) +(defun lisp--el-non-funcall-position-p (pos) "Heuristically determine whether POS is an evaluated position." - (setf pos (or pos (point))) (save-match-data (save-excursion (ignore-errors (goto-char pos) (or (eql (char-before) ?\') - (let ((parent - (progn - (up-list -1) - (cond + (let* ((ppss (syntax-ppss)) + (paren-posns (nth 9 ppss)) + (parent + (when paren-posns + (goto-char (car (last paren-posns))) ;(up-list -1) + (cond ((ignore-errors (and (eql (char-after) ?\() - (progn - (up-list -1) + (when (cdr paren-posns) + (goto-char (car (last paren-posns 2))) (looking-at "(\\_")))) (goto-char (match-end 0)) 'let) -- cgit v1.2.1 From c0c57f8b36d4472296f9bc237a16b9876488472c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 15 Apr 2015 16:50:17 -0400 Subject: Move some Elisp-specific code from lisp-mode.el to elisp-mode.el * lisp/emacs-lisp/lisp-mode.el (lisp--el-font-lock-flush-elisp-buffers): Move to elisp-mode.el. (lisp-mode-variables): (Re)move elisp-specific settings. * lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Add settings removed from lisp-mode-variables. (elisp--font-lock-flush-elisp-buffers): New function, moved from lisp-mode.el. --- lisp/emacs-lisp/lisp-mode.el | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 45d5a0b410c..26a21d52370 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -218,6 +218,7 @@ (< (point) pos)))))))))) (defun lisp--el-match-keyword (limit) + ;; FIXME: Move to elisp-mode.el. (catch 'found (while (re-search-forward "(\\(\\(?:\\sw\\|\\s_\\)+\\)\\_>" limit t) (let ((sym (intern-soft (match-string 1)))) @@ -228,17 +229,6 @@ (match-beginning 0))))) (throw 'found t)))))) -(defun lisp--el-font-lock-flush-elisp-buffers (&optional file) - ;; Don't flush during load unless called from after-load-functions. - ;; In that case, FILE is non-nil. It's somehow strange that - ;; load-in-progress is t when an after-load-function is called since - ;; that should run *after* the load... - (when (or (not load-in-progress) file) - (dolist (buf (buffer-list)) - (with-current-buffer buf - (when (derived-mode-p 'emacs-lisp-mode) - (font-lock-flush)))))) - (pcase-let ((`(,vdefs ,tdefs ,el-defs-re ,cl-defs-re @@ -583,10 +573,6 @@ font-lock keywords will not be case sensitive." (font-lock-syntactic-face-function . lisp-font-lock-syntactic-face-function))) (setq-local prettify-symbols-alist lisp--prettify-symbols-alist) - (when elisp - (add-hook 'after-load-functions #'lisp--el-font-lock-flush-elisp-buffers) - (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)) -- cgit v1.2.1 From c9a75a4030a556d700fd95222ec0bf4c1a9f67b5 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 20 Apr 2015 21:55:00 -0400 Subject: Fix byte-compiler warnings about looking-back. * lisp/vc/log-view.el (log-view-end-of-defun-1): * lisp/textmodes/tex-mode.el (latex-forward-sexp-1): * lisp/textmodes/reftex-ref.el (reftex-goto-label): * lisp/textmodes/bibtex.el (bibtex-insert-kill): * lisp/progmodes/sh-script.el (sh--maybe-here-document): * lisp/progmodes/ruby-mode.el (ruby-end-of-defun): * lisp/progmodes/ada-mode.el (ada-in-numeric-literal-p): * lisp/org/org.el (org-insert-heading, org-sort-entries): * lisp/org/org-mouse.el (org-mouse-end-headline) (org-mouse-context-menu): * lisp/org/org-clock.el (org-clock-cancel): * lisp/man.el (Man-default-man-entry): * lisp/mail/rmail.el (rmail-get-new-mail, rmail-insert-inbox-text) (rmail-ensure-blank-line): * lisp/mail/footnote.el (Footnote-delete-footnote): * lisp/mail/emacsbug.el (report-emacs-bug): * lisp/info.el (Info-follow-reference, Info-fontify-node): * lisp/info-look.el (info-lookup-guess-custom-symbol): * lisp/help-fns.el (help-fns--key-bindings): * lisp/files.el (hack-local-variables): * lisp/emulation/viper-ex.el (viper-get-ex-token, ex-cmd-complete) (viper-get-ex-pat, ex-expand-filsyms, viper-get-ex-file) (viper-complete-filename-or-exit): * lisp/emulation/viper-cmd.el (viper-backward-indent): * lisp/emacs-lisp/lisp-mode.el (calculate-lisp-indent): * lisp/emacs-lisp/elint.el (elint-get-top-forms): * lisp/cus-edit.el (custom-face-edit-value-create): * lisp/calendar/todo-mode.el (todo-set-item-priority) (todo-filter-items-1, todo-convert-legacy-files) (todo-prefix-overlays): Add explicit second arg to looking-back. --- lisp/emacs-lisp/lisp-mode.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp/lisp-mode.el') diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 26a21d52370..108d5ccb0e3 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -855,9 +855,10 @@ is the buffer position of the start of the containing expression." ;; Handle prefix characters and whitespace ;; following an open paren. (Bug#1012) (backward-prefix-chars) - (while (and (not (looking-back "^[ \t]*\\|([ \t]+")) - (or (not containing-sexp) - (< (1+ containing-sexp) (point)))) + (while (not (or (looking-back "^[ \t]*\\|([ \t]+" + (line-beginning-position)) + (and containing-sexp + (>= (1+ containing-sexp) (point))))) (forward-sexp -1) (backward-prefix-chars)) (setq calculate-lisp-indent-last-sexp (point))) -- cgit v1.2.1