diff options
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 48 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/hideshow.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/js.el | 27 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 20 | ||||
| -rw-r--r-- | lisp/progmodes/sql.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/vhdl-mode.el | 43 | ||||
| -rw-r--r-- | lisp/progmodes/xref.el | 4 | 
8 files changed, 96 insertions, 53 deletions
| diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index e84c4cebf69..fd7aa50840f 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -313,7 +313,8 @@ comment at the start of cc-engine.el for more info."  		   (c-macro-is-genuine-p))  	      (progn  		(setq c-macro-cache (cons (point) nil) -		      c-macro-cache-start-pos here) +		      c-macro-cache-start-pos here +		      c-macro-cache-syntactic nil)  		t)  	    (goto-char here)  	    nil)))))) @@ -344,7 +345,8 @@ comment at the start of cc-engine.el for more info."  		(forward-char)  		t)))       (when (car c-macro-cache) -       (setcdr c-macro-cache (point))))) +       (setcdr c-macro-cache (point)) +       (setq c-macro-cache-syntactic nil))))  (defun c-syntactic-end-of-macro ()    ;; Go to the end of a CPP directive, or a "safe" pos just before. @@ -364,7 +366,8 @@ comment at the start of cc-engine.el for more info."  	(goto-char c-macro-cache-syntactic)        (setq s (parse-partial-sexp here there))        (while (and (or (nth 3 s)	 ; in a string -		      (nth 4 s)) ; in a comment (maybe at end of line comment) +		      (and (nth 4 s) ; in a comment (maybe at end of line comment) +			   (not (eq (nth 7 s) 'syntax-table)))) ; Not a pseudo comment  		  (> there here))	; No infinite loops, please.  	(setq there (1- (nth 8 s)))  	(setq s (parse-partial-sexp here there))) @@ -389,7 +392,8 @@ comment at the start of cc-engine.el for more info."  		  (> there here))	; No infinite loops, please.  	(setq here (1+ (nth 8 s)))  	(setq s (parse-partial-sexp here there))) -      (when (nth 4 s) +      (when (and (nth 4 s) +		 (not (eq (nth 7 s) 'syntax-table))) ; no pseudo comments.  	(goto-char (1- (nth 8 s))))        (setq c-macro-cache-no-comment (point)))      (point))) @@ -2407,7 +2411,9 @@ comment at the start of cc-engine.el for more info."  	       (s (parse-partial-sexp base here nil nil s))  	       ty)  	  (cond -	   ((or (nth 3 s) (nth 4 s))	; in a string or comment +	   ((or (nth 3 s) +		(and (nth 4 s) +		     (not (eq (nth 7 s) 'syntax-table)))) ; in a string or comment  	    (setq ty (cond  		      ((nth 3 s) 'string)  		      ((nth 7 s) 'c++) @@ -2453,7 +2459,9 @@ comment at the start of cc-engine.el for more info."  	       (s (parse-partial-sexp base here nil nil s))  	       ty start)  	  (cond -	   ((or (nth 3 s) (nth 4 s))	; in a string or comment +	   ((or (nth 3 s) +		(and (nth 4 s) +		     (not (eq (nth 7 s) 'syntax-table)))) ; in a string or comment  	    (setq ty (cond  		      ((nth 3 s) 'string)  		      ((nth 7 s) 'c++) @@ -2479,7 +2487,7 @@ comment at the start of cc-engine.el for more info."  	   (t (list s)))))))) -(defsubst c-state-pp-to-literal (from to &optional not-in-delimiter) +(defun c-state-pp-to-literal (from to &optional not-in-delimiter)    ;; Do a parse-partial-sexp from FROM to TO, returning either    ;;     (STATE TYPE (BEG . END))     if TO is in a literal; or    ;;     (STATE)                      otherwise, @@ -2498,7 +2506,9 @@ comment at the start of cc-engine.el for more info."        (let ((s (parse-partial-sexp from to))  	    ty co-st)  	(cond -	 ((or (nth 3 s) (nth 4 s))	; in a string or comment +	 ((or (nth 3 s) +	      (and (nth 4 s) +		   (not (eq (nth 7 s) 'syntax-table))))	; in a string or comment  	  (setq ty (cond  		    ((nth 3 s) 'string)  		    ((nth 7 s) 'c++) @@ -2560,7 +2570,8 @@ comment at the start of cc-engine.el for more info."    (cond     ((nth 3 state)			; A string      (list (point) (nth 3 state) (nth 8 state))) -   ((nth 4 state)			; A comment +   ((and (nth 4 state)			; A comment +	 (not (eq (nth 7 state) 'syntax-table))) ; but not a psuedo comment.      (list (point)  	  (if (eq (nth 7 state) 1) 'c++ 'c)  	  (nth 8 state))) @@ -2697,7 +2708,7 @@ comment at the start of cc-engine.el for more info."      (widen)      (save-excursion        (let ((pos (c-state-safe-place here))) -	    (car (cddr (c-state-pp-to-literal pos here))))))) +	(car (cddr (c-state-pp-to-literal pos here)))))))  (defsubst c-state-lit-beg (pos)    ;; Return the start of the literal containing POS, or POS itself. @@ -2708,7 +2719,8 @@ comment at the start of cc-engine.el for more info."    ;; Return a position outside of a string/comment/macro at or before POS.    ;; STATE is the parse-partial-sexp state at POS.    (let ((res (if (or (nth 3 state)	; in a string? -		     (nth 4 state))	; in a comment? +		     (and (nth 4 state) +			  (not (eq (nth 7 state) 'syntax-table)))) ; in a comment?  		 (nth 8 state)  	       pos)))      (save-excursion @@ -3467,7 +3479,7 @@ comment at the start of cc-engine.el for more info."       ((and (consp (car c-state-cache))  	   (> (cdar c-state-cache) here))        ;; CASE 1: The top of the cache is a brace pair which now encloses -      ;; `here'.  As good-pos, return the address. of the "{".  Since we've no +      ;; `here'.  As good-pos, return the address of the "{".  Since we've no        ;; knowledge of what's inside these braces, we have no alternative but        ;; to direct the caller to scan the buffer from the opening brace.        (setq pos (caar c-state-cache)) @@ -4952,7 +4964,8 @@ comment at the start of cc-engine.el for more info."  	 (lit-limits  	  (if lim  	      (let ((s (parse-partial-sexp lim (point)))) -		(when (or (nth 3 s) (nth 4 s)) +		(when (or (nth 3 s) +			  (and (nth 4 s) (not (eq (nth 7 s) 'syntax-table))))  		  (cons (nth 8 s)  			(progn (parse-partial-sexp (point) (point-max)  						   nil nil @@ -5005,7 +5018,8 @@ point isn't in one.  SAFE-POS, if non-nil, is a position before point which is  a known \"safe position\", i.e. outside of any string or comment."    (if safe-pos        (let ((s (parse-partial-sexp safe-pos (point)))) -	(and (or (nth 3 s) (nth 4 s)) +	(and (or (nth 3 s) +		 (and (nth 4 s) (not (eq (nth 7 s) 'syntax-table))))  	     (nth 8 s)))      (car (cddr (c-state-semi-pp-to-literal (point)))))) @@ -5106,7 +5120,8 @@ comment at the start of cc-engine.el for more info."  		 'syntax-table))	; stop-comment  	;; Gather details of the non-literal-bit - starting pos and size. -	(setq size (- (if (or (nth 4 s) (nth 3 s)) +	(setq size (- (if (or (and (nth 4 s) (not (eq (nth 7 s) 'syntax-table))) +			      (nth 3 s))  			  (nth 8 s)  			(point))  		      pos)) @@ -5114,7 +5129,8 @@ comment at the start of cc-engine.el for more info."  	    (setq stack (cons (cons pos size) stack)))  	;; Move forward to the end of the comment/string. -	(if (or (nth 4 s) (nth 3 s)) +	(if (or (and (nth 4 s) (not (eq (nth 7 s) 'syntax-table))) +		(nth 3 s))  	    (setq s (parse-partial-sexp  		     (point)  		     start diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 7e3c6ba15a5..e2969c607a5 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -1068,7 +1068,8 @@ Note that the style variables are always made local to the buffer."  			(parse-partial-sexp pps-position (point) nil nil pps-state)  			pps-position (point))  		  (or (nth 3 pps-state)	   ; in a string? -		      (nth 4 pps-state)))) ; in a comment? +		      (and (nth 4 pps-state) +			   (not (eq (nth 7 pps-state) 'syntax-table)))))) ; in a comment?  	  (goto-char (match-beginning 1))  	  (setq mbeg (point))  	  (if (> (c-no-comment-end-of-macro) mbeg) diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index 0e4e67018ed..5328526abd9 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -582,7 +582,7 @@ and then further adjusted to be at the end of the line."  	  (setq p (line-end-position)))  	;; `q' is the point at the end of the block  	(hs-forward-sexp mdata 1) -	(setq q (if (looking-back hs-block-end-regexp) +	(setq q (if (looking-back hs-block-end-regexp nil)  		    (match-beginning 0)  		  (point)))          (when (and (< p q) (> (count-lines p q) 1)) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 54df3913fc6..74dd4add9e2 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -574,8 +574,8 @@ then the \".\"s will be lined up:      (define-key keymap [(control ?c) (control ?j)] #'js-set-js-context)      (define-key keymap [(control meta ?x)] #'js-eval-defun)      (define-key keymap [(meta ?.)] #'js-find-symbol) -    (easy-menu-define nil keymap "Javascript Menu" -      '("Javascript" +    (easy-menu-define nil keymap "JavaScript Menu" +      '("JavaScript"          ["Select New Mozilla Context..." js-set-js-context           (fboundp #'inferior-moz-process)]          ["Evaluate Expression in Mozilla Context..." js-eval @@ -1712,7 +1712,7 @@ This performs fontification according to `js--class-styles'."                nil))))))  (defun js-syntax-propertize (start end) -  ;; Javascript allows immediate regular expression objects, written /.../. +  ;; JavaScript allows immediate regular expression objects, written /.../.    (goto-char start)    (js-syntax-propertize-regexp end)    (funcall @@ -1720,10 +1720,10 @@ This performs fontification according to `js--class-styles'."      ;; Distinguish /-division from /-regexp chars (and from /-comment-starter).      ;; FIXME: Allow regexps after infix ops like + ...      ;; https://developer.mozilla.org/en/JavaScript/Reference/Operators -    ;; We can probably just add +, -, !, <, >, %, ^, ~, |, &, ?, : at which +    ;; We can probably just add +, -, <, >, %, ^, ~, ?, : at which      ;; point I think only * and / would be missing which could also be added,      ;; but need care to avoid affecting the // and */ comment markers. -    ("\\(?:^\\|[=([{,:;]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]" +    ("\\(?:^\\|[=([{,:;|&!]\\|\\_<return\\_>\\)\\(?:[ \t]\\)*\\(/\\)[^/*]"       (1 (ignore  	 (forward-char -1)           (when (or (not (memq (char-after (match-beginning 0)) '(?\s ?\t))) @@ -2710,7 +2710,7 @@ current buffer.  Pushes a mark onto the tag ring just like  ;;; MozRepl integration  (define-error 'js-moz-bad-rpc "Mozilla RPC Error") ;; '(timeout error)) -(define-error 'js-js-error "Javascript Error") ;; '(js-error error)) +(define-error 'js-js-error "JavaScript Error") ;; '(js-error error))  (defun js--wait-for-matching-output    (process regexp timeout &optional start) @@ -3214,7 +3214,7 @@ with `js--js-encode-value'."  Inside the lexical scope of `with-js', `js?', `js!',  `js-new', `js-eval', `js-list', `js<', `js>', `js-get-service',  `js-create-instance', and `js-qi' are defined." - +  (declare (indent 0) (debug t))    `(progn       (js--js-enter-repl)       (unwind-protect @@ -3391,7 +3391,7 @@ With argument, run even if no intervening GC has happened."  (defun js-eval (js)    "Evaluate the JavaScript in JS and return JSON-decoded result." -  (interactive "MJavascript to evaluate: ") +  (interactive "MJavaScript to evaluate: ")    (with-js     (let* ((content-window (js--js-content-window                             (js--get-js-context))) @@ -3431,11 +3431,8 @@ left-to-right."                           (eq (cl-fifth window-info) 2))                do (push window-info windows)) -     (cl-loop for window-info in windows -              for window = (cl-first window-info) -              collect (list (cl-second window-info) -                            (cl-third window-info) -                            window) +     (cl-loop for (window title location) in windows +              collect (list title location window)                for gbrowser = (js< window "gBrowser")                if (js-handle? gbrowser) @@ -3668,7 +3665,7 @@ Change with `js-set-js-context'.")  (defun js-set-js-context (context)    "Set the JavaScript context to CONTEXT.  When called interactively, prompt for CONTEXT." -  (interactive (list (js--read-tab "Javascript Context: "))) +  (interactive (list (js--read-tab "JavaScript Context: ")))    (setq js--js-context context))  (defun js--get-js-context () @@ -3682,7 +3679,7 @@ If one hasn't been set, or if it's stale, prompt for a new one."                 (`browser (not (js? (js< (cdr js--js-context)                                          "contentDocument"))))                 (x (error "Unmatched case in js--get-js-context: %S" x)))) -     (setq js--js-context (js--read-tab "Javascript Context: "))) +     (setq js--js-context (js--read-tab "JavaScript Context: ")))     js--js-context))  (defun js--js-content-window (context) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d8262dd0a75..90b5e4e0dc6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4693,7 +4693,8 @@ likely an invalid python file."      (let ((dedenter-pos (python-info-dedenter-statement-p)))        (when dedenter-pos          (goto-char dedenter-pos) -        (let* ((pairs '(("elif" "elif" "if") +        (let* ((cur-line (line-beginning-position)) +               (pairs '(("elif" "elif" "if")                          ("else" "if" "elif" "except" "for" "while")                          ("except" "except" "try")                          ("finally" "else" "except" "try"))) @@ -4709,7 +4710,22 @@ likely an invalid python file."                (let ((indentation (current-indentation)))                  (when (and (not (memq indentation collected-indentations))                             (or (not collected-indentations) -                               (< indentation (apply #'min collected-indentations)))) +                               (< indentation (apply #'min collected-indentations))) +                           ;; There must be no line with indentation +                           ;; smaller than `indentation' (except for +                           ;; blank lines) between the found opening +                           ;; block and the current line, otherwise it +                           ;; is not an opening block. +                           (save-excursion +                             (forward-line) +                             (let ((no-back-indent t)) +                               (save-match-data +                                 (while (and (< (point) cur-line) +                                             (setq no-back-indent +                                                   (or (> (current-indentation) indentation) +                                                       (python-info-current-line-empty-p)))) +                                   (forward-line))) +                               no-back-indent)))                    (setq collected-indentations                          (cons indentation collected-indentations))                    (when (member (match-string-no-properties 0) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 71563486ecd..88683431290 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -2790,7 +2790,7 @@ local variable."      ;; Iterate until we've moved the desired number of stmt ends      (while (not (= (cl-signum arg) 0))        ;; if we're looking at the terminator, jump by 2 -      (if (or (and (> 0 arg) (looking-back term)) +      (if (or (and (> 0 arg) (looking-back term nil))                (and (< 0 arg) (looking-at term)))            (setq n 2)          (setq n 1)) diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index 0e8ff525e62..6c76d7e4ad2 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -126,6 +126,14 @@  ;;; Code: +(eval-when-compile (require 'cl)) +(eval-and-compile +  ;; Before Emacs-24.4, `pushnew' expands to runtime calls to `cl-adjoin' +  ;; even for relatively simple cases such as used here.  We only test <25 +  ;; because it's easier and sufficient. +  (when (or (featurep 'xemacs) (< emacs-major-version 25)) +    (require 'cl))) +  ;; Emacs 21+ handling  (defconst vhdl-emacs-21 (and (<= 21 emacs-major-version) (not (featurep 'xemacs)))    "Non-nil if GNU Emacs 21, 22, ... is used.") @@ -14314,7 +14322,7 @@ of PROJECT."        (vhdl-scan-directory-contents dir-name project nil  				    (format "(%s/%s) " act-dir num-dir)  				    (cdr dir-list)) -      (add-to-list 'dir-list-tmp (file-name-directory dir-name)) +      (pushnew (file-name-directory dir-name) dir-list-tmp :test #'equal)        (setq dir-list (cdr dir-list)  	    act-dir (1+ act-dir)))      (vhdl-aput 'vhdl-directory-alist project (list (nreverse dir-list-tmp))) @@ -16406,8 +16414,8 @@ component instantiation."  	     (if (or (member constant-name single-list)  		     (member constant-name multi-list))  		 (progn (setq single-list (delete constant-name single-list)) -			(add-to-list 'multi-list constant-name)) -	       (add-to-list 'single-list constant-name)) +			(pushnew constant-name multi-list :test #'equal)) +	       (pushnew constant-name single-list :test #'equal))  	     (unless (match-string 1)  	       (setq generic-alist (cdr generic-alist)))  	     (vhdl-forward-syntactic-ws)) @@ -16433,12 +16441,12 @@ component instantiation."  		     (member signal-name multi-out-list))  		 (setq single-out-list (delete signal-name single-out-list))  		 (setq multi-out-list (delete signal-name multi-out-list)) -		 (add-to-list 'local-list signal-name)) +		 (pushnew signal-name local-list :test #'equal))  		((member signal-name single-in-list)  		 (setq single-in-list (delete signal-name single-in-list)) -		 (add-to-list 'multi-in-list signal-name)) +		 (pushnew signal-name multi-in-list :test #'equal))  		((not (member signal-name multi-in-list)) -		 (add-to-list 'single-in-list signal-name))) +		 (pushnew signal-name single-in-list :test #'equal)))  	     ;; output signal  	     (cond  	      ((member signal-name local-list) @@ -16447,17 +16455,18 @@ component instantiation."  		   (member signal-name multi-in-list))  	       (setq single-in-list (delete signal-name single-in-list))  	       (setq multi-in-list (delete signal-name multi-in-list)) -	       (add-to-list 'local-list signal-name)) +	       (pushnew signal-name local-list :test #'equal))  	      ((member signal-name single-out-list)  	       (setq single-out-list (delete signal-name single-out-list)) -	       (add-to-list 'multi-out-list signal-name)) +	       (pushnew signal-name multi-out-list :test #'equal))  	      ((not (member signal-name multi-out-list)) -	       (add-to-list 'single-out-list signal-name)))) +	       (pushnew signal-name single-out-list :test #'equal))))  	   (unless (match-string 1)  	     (setq port-alist (cdr port-alist)))  	   (vhdl-forward-syntactic-ws))  	 (push (list inst-name (nreverse constant-alist) -		     (nreverse signal-alist)) inst-alist)) +		     (nreverse signal-alist)) +               inst-alist))         ;; prepare signal insertion         (vhdl-goto-marker arch-decl-pos)         (forward-line 1) @@ -16534,14 +16543,14 @@ component instantiation."  			 generic-end-pos  			 (vhdl-compose-insert-generic constant-entry)))  		  (setq generic-pos (point-marker)) -		  (add-to-list 'written-list constant-name)) +		  (pushnew constant-name written-list :test #'equal))  		 (t  		  (vhdl-goto-marker  		   (vhdl-max-marker generic-inst-pos generic-pos))  		  (setq generic-end-pos  			(vhdl-compose-insert-generic constant-entry))  		  (setq generic-inst-pos (point-marker)) -		    (add-to-list 'written-list constant-name)))) +		    (pushnew constant-name written-list :test #'equal))))  	   (setq constant-alist (cdr constant-alist)))  	 (when (/= constant-temp-pos generic-inst-pos)  	   (vhdl-goto-marker (vhdl-max-marker constant-temp-pos generic-pos)) @@ -16560,14 +16569,14 @@ component instantiation."  			(vhdl-max-marker  			 port-end-pos (vhdl-compose-insert-port signal-entry)))  		  (setq port-in-pos (point-marker)) -		  (add-to-list 'written-list signal-name)) +		  (pushnew signal-name written-list :test #'equal))  		 ((member signal-name multi-out-list)  		  (vhdl-goto-marker (vhdl-max-marker port-out-pos port-in-pos))  		  (setq port-end-pos  			(vhdl-max-marker  			 port-end-pos (vhdl-compose-insert-port signal-entry)))  		  (setq port-out-pos (point-marker)) -		  (add-to-list 'written-list signal-name)) +		  (pushnew signal-name written-list :test #'equal))  		 ((or (member signal-name single-in-list)  		      (member signal-name single-out-list))  		  (vhdl-goto-marker @@ -16576,12 +16585,12 @@ component instantiation."  		    (vhdl-max-marker port-out-pos port-in-pos)))  		  (setq port-end-pos (vhdl-compose-insert-port signal-entry))  		  (setq port-inst-pos (point-marker)) -		  (add-to-list 'written-list signal-name)) +		  (pushnew signal-name written-list :test #'equal))  		 ((equal (upcase (nth 2 signal-entry)) "OUT")  		  (vhdl-goto-marker signal-pos)  		  (vhdl-compose-insert-signal signal-entry)  		  (setq signal-pos (point-marker)) -		  (add-to-list 'written-list signal-name))) +		  (pushnew signal-name written-list :test #'equal)))  	   (setq signal-alist (cdr signal-alist)))  	 (when (/= port-temp-pos port-inst-pos)  	   (vhdl-goto-marker @@ -16932,7 +16941,7 @@ no project is defined."    "Remove duplicate elements from IN-LIST."    (let (out-list)      (while in-list -      (add-to-list 'out-list (car in-list)) +      (pushnew (car in-list) out-list :test #'equal)        (setq in-list (cdr in-list)))      out-list)) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index d8098c5a54a..a507755d42e 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -918,6 +918,10 @@ IGNORES is a list of glob patterns."    (grep-compute-defaults)    (defvar grep-find-template)    (defvar grep-highlight-matches) +  ;; 'grep -E -foo' results in 'grep: oo: No such file or directory'. +  ;; while 'grep -e -foo' inexplicably doesn't. +  (when (eq (aref regexp 0) ?-) +    (setq regexp (concat "\\" regexp)))    (let* ((grep-find-template (replace-regexp-in-string "-e " "-E "                                                         grep-find-template t t))           (grep-highlight-matches nil) | 
