diff options
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 32 | ||||
| -rw-r--r-- | lisp/progmodes/gdb-mi.el | 13 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 9 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 46 | ||||
| -rw-r--r-- | lisp/progmodes/sh-script.el | 1 | ||||
| -rw-r--r-- | lisp/progmodes/sql.el | 91 | ||||
| -rw-r--r-- | lisp/progmodes/subword.el | 12 |
7 files changed, 123 insertions, 81 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 9077bdbb513..a3bd000a4f3 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -6892,7 +6892,7 @@ comment at the start of cc-engine.el for more info." (while (and (looking-at c-type-decl-prefix-key) (if (and (c-major-mode-is 'c++-mode) (match-beginning 3)) - ;; If the second submatch matches in C++ then + ;; If the third submatch matches in C++ then ;; we're looking at an identifier that's a ;; prefix only if it specifies a member pointer. (when (setq got-identifier (c-forward-name)) @@ -7193,19 +7193,23 @@ comment at the start of cc-engine.el for more info." ;; uncommon (e.g. some placements of "const" in C++) it's not worth ;; the effort to look for them.) - (unless (or at-decl-end (looking-at "=[^=]")) - ;; If this is a declaration it should end here or its initializer(*) - ;; should start here, so check for allowed separation tokens. Note - ;; that this rule doesn't work e.g. with a K&R arglist after a - ;; function header. - ;; - ;; *) Don't check for C++ style initializers using parens - ;; since those already have been matched as suffixes. - ;; - ;; If `at-decl-or-cast' is then we've found some other sign that - ;; it's a declaration or cast, so then it's probably an - ;; invalid/unfinished one. - (throw 'at-decl-or-cast at-decl-or-cast)) +;;; 2008-04-16: commented out the next form, to allow the function to recognize +;;; "foo (int bar)" in CC (an implicit type (in class foo) without a semicolon) +;;; as a(n almost complete) declaration, enabling it to be fontified. + ;; CASE 13 + ;; (unless (or at-decl-end (looking-at "=[^=]")) + ;; If this is a declaration it should end here or its initializer(*) + ;; should start here, so check for allowed separation tokens. Note + ;; that this rule doesn't work e.g. with a K&R arglist after a + ;; function header. + ;; + ;; *) Don't check for C++ style initializers using parens + ;; since those already have been matched as suffixes. + ;; + ;; If `at-decl-or-cast' is then we've found some other sign that + ;; it's a declaration or cast, so then it's probably an + ;; invalid/unfinished one. + ;; (throw 'at-decl-or-cast at-decl-or-cast)) ;; Below are tests that only should be applied when we're certain to ;; not have parsed halfway through an expression. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 10472ec5815..4b51a5e7835 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -290,9 +290,8 @@ discard all handlers having a token number less than TOKEN-NUMBER." (lambda (handler) "Discard any HANDLER with a token number `<=' than TOKEN-NUMBER." (when (< (gdb-handler-token-number handler) token-number) - (message (format - "WARNING! Discarding GDB handler with token #%d\n" - (gdb-handler-token-number handler)))) + (message "WARNING! Discarding GDB handler with token #%d\n" + (gdb-handler-token-number handler))) (<= (gdb-handler-token-number handler) token-number)) gdb-handler-list)) @@ -1490,7 +1489,7 @@ this trigger is subscribed to `gdb-buf-publisher' and called with split-horizontal) `(defun ,name (&optional thread) ,(when doc doc) - (message thread) + (message "%s" thread) (gdb-preempt-existing-or-display-buffer (gdb-get-buffer-create ,buffer thread) ,split-horizontal))) @@ -2445,9 +2444,9 @@ current thread and update GDB buffers." (if (or (eq gdb-switch-reasons t) (member reason gdb-switch-reasons)) (when (not (string-equal gdb-thread-number thread-id)) - (message (concat "Switched to thread " thread-id)) + (message "Switched to thread %s" thread-id) (gdb-setq-thread-number thread-id)) - (message (format "Thread %s stopped" thread-id))))) + (message "Thread %s stopped" thread-id)))) ;; Print "(gdb)" to GUD console (when gdb-first-done-or-error @@ -2500,7 +2499,7 @@ current thread and update GDB buffers." ;; MI error - send to minibuffer (when (eq type 'error) ;; Skip "msg=" from `output-field' - (message (read (substring output-field 4))) + (message "%s" (read (substring output-field 4))) ;; Don't send to the console twice. (If it is a console error ;; it is also in the console stream.) (setq output-field nil))) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 915b52ce04d..62870f9085b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3091,7 +3091,12 @@ you are doing." ;; Stop collecting nodes after moving to a position with ;; indentation equaling min-indent. This is specially ;; useful for navigating nested definitions recursively. - tree) + (if (> num-children 0) + tree + ;; When there are no children, the collected tree is a + ;; single node intended to be added in the list of defuns + ;; of its parent. + (car tree))) (t (python-imenu--build-tree min-indent @@ -3131,7 +3136,7 @@ you are doing." (cons (prog1 (python-imenu--build-tree - prev-indent indent 1 (list (cons label pos))) + prev-indent indent 0 (list (cons label pos))) ;; Adjustment: after scanning backwards ;; for all deeper children, we need to ;; continue our scan for a parent from diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 06dffd80d88..c8fae7ba1e6 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -46,11 +46,6 @@ :prefix "ruby-" :group 'languages) -(defconst ruby-keyword-end-re - (if (string-match "\\_>" "ruby") - "\\_>" - "\\>")) - (defconst ruby-block-beg-keywords '("class" "module" "def" "if" "unless" "case" "while" "until" "for" "begin" "do") "Keywords at the beginning of blocks.") @@ -60,7 +55,7 @@ "Regexp to match the beginning of blocks.") (defconst ruby-non-block-do-re - (concat (regexp-opt '("while" "until" "for" "rescue") t) ruby-keyword-end-re) + (regexp-opt '("while" "until" "for" "rescue") 'symbols) "Regexp to match keywords that nest without blocks.") (defconst ruby-indent-beg-re @@ -696,7 +691,7 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'." ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>")) (and (save-match-data - (or (not (looking-at (concat "do" ruby-keyword-end-re))) + (or (not (looking-at "do\\_>")) (save-excursion (back-to-indentation) (not (looking-at ruby-non-block-do-re))))) @@ -1718,14 +1713,16 @@ See the definition of `ruby-font-lock-syntactic-keywords'." "The syntax table to use for fontifying Ruby mode buffers. See `font-lock-syntax-table'.") +(defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$]\\|\\.\\.\\)") + (defconst ruby-font-lock-keywords (list ;; functions '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)" 1 font-lock-function-name-face) + ;; keywords (list (concat - "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" - ;; keywords + ruby-font-lock-keyword-beg-re (regexp-opt '("alias" "and" @@ -1760,11 +1757,14 @@ See `font-lock-syntax-table'.") "when" "while" "yield") - 'symbols) - "\\|" + 'symbols)) + 1 'font-lock-keyword-face) + ;; some core methods + (list (concat + ruby-font-lock-keyword-beg-re (regexp-opt - ;; built-in methods on Kernel - '("__callee__" + '(;; built-in methods on Kernel + "__callee__" "__dir__" "__method__" "abort" @@ -1823,20 +1823,17 @@ See `font-lock-syntax-table'.") "public" "refine" "using") - 'symbols) - "\\)") - 2 - '(if (match-beginning 4) - font-lock-builtin-face - font-lock-keyword-face)) + 'symbols)) + 1 'font-lock-builtin-face) ;; Perl-ish keywords "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" ;; here-doc beginnings `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) 'font-lock-string-face)) ;; variables - '("\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>" - 2 font-lock-variable-name-face) + `(,(concat ruby-font-lock-keyword-beg-re + "\\_<\\(nil\\|self\\|true\\|false\\)\\>") + 1 font-lock-variable-name-face) ;; keywords that evaluate to certain values '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face) ;; symbols @@ -1851,6 +1848,11 @@ See `font-lock-syntax-table'.") '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" 1 (unless (eq ?\( (char-after)) font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) + ;; conversion methods on Kernel + (list (concat ruby-font-lock-keyword-beg-re + (regexp-opt '("Array" "Complex" "Float" "Hash" + "Integer" "Rational" "String") 'symbols)) + 1 font-lock-builtin-face) ;; expression expansion '(ruby-match-expression-expansion 2 font-lock-variable-name-face t) @@ -1859,7 +1861,7 @@ See `font-lock-syntax-table'.") 1 font-lock-negation-char-face) ;; character literals ;; FIXME: Support longer escape sequences. - '("\\?\\\\?\\S " 0 font-lock-string-face) + '("\\_<\\?\\\\?\\S " 0 font-lock-string-face) ) "Additional expressions to highlight in Ruby mode.") diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 07e9bb85c4e..29020d95226 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -2401,7 +2401,6 @@ which in this buffer is currently %s. (defun sh-read-variable (var) "Read a new value for indentation variable VAR." - (interactive "*variable? ") ;; to test (let ((minibuffer-help-form `(sh-help-string-for-variable (quote ,var))) val) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 940afc3d5f4..56a6f155f31 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -4,7 +4,7 @@ ;; Author: Alex Schroeder <alex@gnu.org> ;; Maintainer: Michael Mauger <michael@mauger.com> -;; Version: 3.2 +;; Version: 3.3 ;; Keywords: comm languages processes ;; URL: http://savannah.gnu.org/projects/emacs/ @@ -233,6 +233,7 @@ (require 'regexp-opt)) (require 'custom) (require 'thingatpt) +(require 'view) (defvar font-lock-keyword-face) (defvar font-lock-set-defaults) @@ -246,7 +247,7 @@ :group 'languages :group 'processes) -;; These four variables will be used as defaults, if set. +;; These five variables will be used as defaults, if set. (defcustom sql-user "" "Default username." @@ -437,7 +438,7 @@ file. Since that is a plaintext file, this could be dangerous." :completion-object sql-oracle-completion-object :prompt-regexp "^SQL> " :prompt-length 5 - :prompt-cont-regexp "^\\s-*[[:digit:]]+ " + :prompt-cont-regexp "^\\(?:[ ][ ][1-9]\\|[ ][1-9][0-9]\\|[1-9][0-9]\\{2\\}\\)[ ]\\{2\\}" :statement sql-oracle-statement-starters :syntax-alist ((?$ . "_") (?# . "_")) :terminator ("\\(^/\\|;\\)$" . "/") @@ -3276,6 +3277,17 @@ Allows the suppression of continuation prompts.") (defvar sql-preoutput-hold nil) +(defun sql-starts-with-prompt-re () + "Anchor the prompt expression at the beginning of the output line. +Remove the start of line regexp." + (replace-regexp-in-string "\\^" "\\\\`" comint-prompt-regexp)) + +(defun sql-ends-with-prompt-re () + "Anchor the prompt expression at the end of the output line. +Remove the start of line regexp from the prompt expression since +it may not follow newline characters in the output line." + (concat (replace-regexp-in-string "\\^" "" sql-prompt-regexp) "\\'")) + (defun sql-interactive-remove-continuation-prompt (oline) "Strip out continuation prompts out of the OLINE. @@ -3293,38 +3305,52 @@ to the next chunk to properly match the broken-up prompt. If the filter gets confused, it should reset and stop filtering to avoid deleting non-prompt output." - (let (did-filter) - (setq oline (concat (or sql-preoutput-hold "") oline) - sql-preoutput-hold nil) - - (if (and comint-prompt-regexp - (integerp sql-output-newline-count) - (>= sql-output-newline-count 1)) - (progn - (while (and (not (string= oline "")) - (> sql-output-newline-count 0) - (string-match comint-prompt-regexp oline) - (= (match-beginning 0) 0)) + (when comint-prompt-regexp + (save-match-data + (let (prompt-found last-nl) - (setq oline (replace-match "" nil nil oline) - sql-output-newline-count (1- sql-output-newline-count) - did-filter t)) + ;; Add this text to what's left from the last pass + (setq oline (concat sql-preoutput-hold oline) + sql-preoutput-hold "") + ;; If we are looking for multiple prompts + (when (and (integerp sql-output-newline-count) + (>= sql-output-newline-count 1)) + ;; Loop thru each starting prompt and remove it + (let ((start-re (sql-starts-with-prompt-re))) + (while (and (not (string= oline "")) + (> sql-output-newline-count 0) + (string-match start-re oline)) + (setq oline (replace-match "" nil nil oline) + sql-output-newline-count (1- sql-output-newline-count) + prompt-found t))) + + ;; If we've found all the expected prompts, stop looking (if (= sql-output-newline-count 0) (setq sql-output-newline-count nil oline (concat "\n" oline)) + ;; Still more possible prompts, leave them for the next pass (setq sql-preoutput-hold oline - oline "")) - - (unless did-filter - (setq oline (or sql-preoutput-hold "") - sql-preoutput-hold nil - sql-output-newline-count nil))) - - (setq sql-output-newline-count nil)) - - oline)) + oline ""))) + + ;; If no prompts were found, stop looking + (unless prompt-found + (setq sql-output-newline-count nil + oline (concat oline sql-preoutput-hold) + sql-preoutput-hold "")) + + ;; Break up output by physical lines if we haven't hit the final prompt + (unless (and (not (string= oline "")) + (string-match (sql-ends-with-prompt-re) oline) + (>= (match-end 0) (length oline))) + (setq last-nl 0) + (while (string-match "\n" oline last-nl) + (setq last-nl (match-end 0))) + (setq sql-preoutput-hold (concat (substring oline last-nl) + sql-preoutput-hold) + oline (substring oline 0 last-nl)))))) + oline) ;;; Sending the region to the SQLi buffer. @@ -3462,7 +3488,8 @@ list of SQLi command strings." :prompt-regexp)) (start nil)) (with-current-buffer buf - (setq view-read-only nil) + (setq-local view-no-disable-on-exit t) + (read-only-mode -1) (unless save-prior (erase-buffer)) (goto-char (point-max)) @@ -3571,8 +3598,8 @@ buffer is popped into a view window." (get-lru-window)))) (with-current-buffer outbuf (set-buffer-modified-p nil) - (setq view-read-only t)) - (view-buffer-other-window outbuf) + (read-only-mode +1)) + (pop-to-buffer outbuf) (when one-win (shrink-window-if-larger-than-buffer))))) @@ -3747,7 +3774,9 @@ must tell Emacs. Here's how to do that in your init file: (setq-local abbrev-all-caps 1) ;; Contains the name of database objects (set (make-local-variable 'sql-contains-names) t) + ;; Set syntax and font-face highlighting ;; Catch changes to sql-product and highlight accordingly + (sql-set-product (or sql-product 'ansi)) ; Fixes bug#13591 (add-hook 'hack-local-variables-hook 'sql-highlight-product t t)) diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index a75bdff27bd..8cf4feb62cb 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el @@ -93,11 +93,11 @@ (defvar subword-backward-function 'subword-backward-internal "Function to call for backward subword movement.") -(defvar subword-forward-regexp - "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" +(defconst subword-forward-regexp + "\\W*\\(\\([[:upper:]]*\\(\\W\\)?\\)[[:lower:][:digit:]]*\\)" "Regexp used by `subword-forward-internal'.") -(defvar subword-backward-regexp +(defconst subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)" "Regexp used by `subword-backward-internal'.") @@ -319,7 +319,11 @@ edit them as words. (> (match-end 0) (point))) (goto-char (cond - ((< 1 (- (match-end 2) (match-beginning 2))) + ((and (< 1 (- (match-end 2) (match-beginning 2))) + ;; If we have an all-caps word with no following lower-case or + ;; non-word letter, don't leave the last char (bug#13758). + (not (and (null (match-beginning 3)) + (eq (match-end 2) (match-end 1))))) (1- (match-end 2))) (t (match-end 0)))) |
