aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorKenichi Handa2012-11-23 23:36:24 +0900
committerKenichi Handa2012-11-23 23:36:24 +0900
commit2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9 (patch)
tree3711b97807201b7eeaa066003b1c3a4ce929e5bb /lisp/progmodes
parente1d276cbf9e18f13101328f56bed1a1c0a66e63a (diff)
parente7d0e5ee247a155a268ffbf80bedbe25e15b5032 (diff)
downloademacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.tar.gz
emacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.zip
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/python.el77
-rw-r--r--lisp/progmodes/sql.el19
2 files changed, 54 insertions, 42 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 949b0252bf1..550c5f5a129 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -202,13 +202,12 @@
202 202
203(require 'ansi-color) 203(require 'ansi-color)
204(require 'comint) 204(require 'comint)
205(eval-when-compile (require 'cl-lib))
205 206
206(eval-when-compile 207;; Avoid compiler warnings
207 (require 'cl) 208(defvar view-return-to-alist)
208 ;; Avoid compiler warnings 209(defvar compilation-error-regexp-alist)
209 (defvar view-return-to-alist) 210(defvar outline-heading-end-regexp)
210 (defvar compilation-error-regexp-alist)
211 (defvar outline-heading-end-regexp))
212 211
213(autoload 'comint-mode "comint") 212(autoload 'comint-mode "comint")
214 213
@@ -364,12 +363,24 @@ This variant of `rx' supports common python named REGEXPS."
364 "Return non-nil if point is on TYPE using SYNTAX-PPSS. 363 "Return non-nil if point is on TYPE using SYNTAX-PPSS.
365TYPE can be `comment', `string' or `paren'. It returns the start 364TYPE can be `comment', `string' or `paren'. It returns the start
366character address of the specified TYPE." 365character address of the specified TYPE."
366 (declare (compiler-macro
367 (lambda (form)
368 (pcase type
369 (`'comment
370 `(let ((ppss (or ,syntax-ppss (syntax-ppss))))
371 (and (nth 4 ppss) (nth 8 ppss))))
372 (`'string
373 `(let ((ppss (or ,syntax-ppss (syntax-ppss))))
374 (and (nth 3 ppss) (nth 8 ppss))))
375 (`'paren
376 `(nth 1 (or ,syntax-ppss (syntax-ppss))))
377 (_ form)))))
367 (let ((ppss (or syntax-ppss (syntax-ppss)))) 378 (let ((ppss (or syntax-ppss (syntax-ppss))))
368 (case type 379 (pcase type
369 (comment (and (nth 4 ppss) (nth 8 ppss))) 380 (`comment (and (nth 4 ppss) (nth 8 ppss)))
370 (string (and (not (nth 4 ppss)) (nth 8 ppss))) 381 (`string (and (nth 3 ppss) (nth 8 ppss)))
371 (paren (nth 1 ppss)) 382 (`paren (nth 1 ppss))
372 (t nil)))) 383 (_ nil))))
373 384
374(defun python-syntax-context-type (&optional syntax-ppss) 385(defun python-syntax-context-type (&optional syntax-ppss)
375 "Return the context type using SYNTAX-PPSS. 386 "Return the context type using SYNTAX-PPSS.
@@ -481,8 +492,8 @@ The type returned can be `comment', `string' or `paren'."
481 (when (re-search-forward re limit t) 492 (when (re-search-forward re limit t)
482 (while (and (python-syntax-context 'paren) 493 (while (and (python-syntax-context 'paren)
483 (re-search-forward re limit t))) 494 (re-search-forward re limit t)))
484 (if (and (not (python-syntax-context 'paren)) 495 (if (not (or (python-syntax-context 'paren)
485 (not (equal (char-after (point-marker)) ?=))) 496 (equal (char-after (point-marker)) ?=)))
486 t 497 t
487 (set-match-data nil))))) 498 (set-match-data nil)))))
488 (1 font-lock-variable-name-face nil nil)) 499 (1 font-lock-variable-name-face nil nil))
@@ -516,7 +527,7 @@ is used to limit the scan."
516 (while (and (< i 3) 527 (while (and (< i 3)
517 (or (not limit) (< (+ point i) limit)) 528 (or (not limit) (< (+ point i) limit))
518 (eq (char-after (+ point i)) quote-char)) 529 (eq (char-after (+ point i)) quote-char))
519 (incf i)) 530 (cl-incf i))
520 i)) 531 i))
521 532
522(defun python-syntax-stringify () 533(defun python-syntax-stringify ()
@@ -723,17 +734,17 @@ START is the buffer position where the sexp starts."
723 (save-restriction 734 (save-restriction
724 (widen) 735 (widen)
725 (save-excursion 736 (save-excursion
726 (case context-status 737 (pcase context-status
727 ('no-indent 0) 738 (`no-indent 0)
728 ;; When point is after beginning of block just add one level 739 ;; When point is after beginning of block just add one level
729 ;; of indentation relative to the context-start 740 ;; of indentation relative to the context-start
730 ('after-beginning-of-block 741 (`after-beginning-of-block
731 (goto-char context-start) 742 (goto-char context-start)
732 (+ (current-indentation) python-indent-offset)) 743 (+ (current-indentation) python-indent-offset))
733 ;; When after a simple line just use previous line 744 ;; When after a simple line just use previous line
734 ;; indentation, in the case current line starts with a 745 ;; indentation, in the case current line starts with a
735 ;; `python-indent-dedenters' de-indent one level. 746 ;; `python-indent-dedenters' de-indent one level.
736 ('after-line 747 (`after-line
737 (- 748 (-
738 (save-excursion 749 (save-excursion
739 (goto-char context-start) 750 (goto-char context-start)
@@ -746,11 +757,11 @@ START is the buffer position where the sexp starts."
746 ;; When inside of a string, do nothing. just use the current 757 ;; When inside of a string, do nothing. just use the current
747 ;; indentation. XXX: perhaps it would be a good idea to 758 ;; indentation. XXX: perhaps it would be a good idea to
748 ;; invoke standard text indentation here 759 ;; invoke standard text indentation here
749 ('inside-string 760 (`inside-string
750 (goto-char context-start) 761 (goto-char context-start)
751 (current-indentation)) 762 (current-indentation))
752 ;; After backslash we have several possibilities. 763 ;; After backslash we have several possibilities.
753 ('after-backslash 764 (`after-backslash
754 (cond 765 (cond
755 ;; Check if current line is a dot continuation. For this 766 ;; Check if current line is a dot continuation. For this
756 ;; the current line must start with a dot and previous 767 ;; the current line must start with a dot and previous
@@ -816,7 +827,7 @@ START is the buffer position where the sexp starts."
816 (+ (current-indentation) python-indent-offset))))) 827 (+ (current-indentation) python-indent-offset)))))
817 ;; When inside a paren there's a need to handle nesting 828 ;; When inside a paren there's a need to handle nesting
818 ;; correctly 829 ;; correctly
819 ('inside-paren 830 (`inside-paren
820 (cond 831 (cond
821 ;; If current line closes the outermost open paren use the 832 ;; If current line closes the outermost open paren use the
822 ;; current indentation of the context-start line. 833 ;; current indentation of the context-start line.
@@ -2164,11 +2175,11 @@ INPUT."
2164 'default) 2175 'default)
2165 (t nil))) 2176 (t nil)))
2166 (completion-code 2177 (completion-code
2167 (case completion-context 2178 (pcase completion-context
2168 (pdb python-shell-completion-pdb-string-code) 2179 (`pdb python-shell-completion-pdb-string-code)
2169 (import python-shell-completion-module-string-code) 2180 (`import python-shell-completion-module-string-code)
2170 (default python-shell-completion-string-code) 2181 (`default python-shell-completion-string-code)
2171 (t nil))) 2182 (_ nil)))
2172 (input 2183 (input
2173 (if (eq completion-context 'import) 2184 (if (eq completion-context 'import)
2174 (replace-regexp-in-string "^[ \t]+" "" line) 2185 (replace-regexp-in-string "^[ \t]+" "" line)
@@ -2492,17 +2503,17 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'."
2492 ;; Docstring styles may vary for oneliners and multi-liners. 2503 ;; Docstring styles may vary for oneliners and multi-liners.
2493 (> (count-matches "\n" str-start-pos str-end-pos) 0)) 2504 (> (count-matches "\n" str-start-pos str-end-pos) 0))
2494 (delimiters-style 2505 (delimiters-style
2495 (case python-fill-docstring-style 2506 (pcase python-fill-docstring-style
2496 ;; delimiters-style is a cons cell with the form 2507 ;; delimiters-style is a cons cell with the form
2497 ;; (START-NEWLINES . END-NEWLINES). When any of the sexps 2508 ;; (START-NEWLINES . END-NEWLINES). When any of the sexps
2498 ;; is NIL means to not add any newlines for start or end 2509 ;; is NIL means to not add any newlines for start or end
2499 ;; of docstring. See `python-fill-docstring-style' for a 2510 ;; of docstring. See `python-fill-docstring-style' for a
2500 ;; graphic idea of each style. 2511 ;; graphic idea of each style.
2501 (django (cons 1 1)) 2512 (`django (cons 1 1))
2502 (onetwo (and multi-line-p (cons 1 2))) 2513 (`onetwo (and multi-line-p (cons 1 2)))
2503 (pep-257 (and multi-line-p (cons nil 2))) 2514 (`pep-257 (and multi-line-p (cons nil 2)))
2504 (pep-257-nn (and multi-line-p (cons nil 1))) 2515 (`pep-257-nn (and multi-line-p (cons nil 1)))
2505 (symmetric (and multi-line-p (cons 1 1))))) 2516 (`symmetric (and multi-line-p (cons 1 1)))))
2506 (docstring-p (save-excursion 2517 (docstring-p (save-excursion
2507 ;; Consider docstrings those strings which 2518 ;; Consider docstrings those strings which
2508 ;; start on a line by themselves. 2519 ;; start on a line by themselves.
@@ -2703,7 +2714,7 @@ The skeleton will be bound to python-skeleton-NAME."
2703 (easy-menu-add-item 2714 (easy-menu-add-item
2704 nil '("Python" "Skeletons") 2715 nil '("Python" "Skeletons")
2705 `[,(format 2716 `[,(format
2706 "Insert %s" (caddr (split-string (symbol-name skeleton) "-"))) 2717 "Insert %s" (nth 2 (split-string (symbol-name skeleton) "-")))
2707 ,skeleton t])))) 2718 ,skeleton t]))))
2708 2719
2709;;; FFAP 2720;;; FFAP
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 64b87d9e436..d84d57cad22 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -736,15 +736,15 @@ this variable is nil, that buffer is shown using
736 736
737(defvar sql-imenu-generic-expression 737(defvar sql-imenu-generic-expression
738 ;; Items are in reverse order because they are rendered in reverse. 738 ;; Items are in reverse order because they are rendered in reverse.
739 '(("Rules/Defaults" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(rule\\|default\\)\\s-+\\(\\w+\\)" 3) 739 '(("Rules/Defaults" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*\\(?:rule\\|default\\)\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\s-+\\(\\w+\\)" 1)
740 ("Sequences" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*sequence\\s-+\\(\\w+\\)" 2) 740 ("Sequences" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*sequence\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
741 ("Triggers" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*trigger\\s-+\\(\\w+\\)" 2) 741 ("Triggers" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*trigger\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
742 ("Functions" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?function\\s-+\\(\\w+\\)" 3) 742 ("Functions" "^\\s-*\\(?:create\\s-+\\(?:\\w+\\s-+\\)*\\)?function\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
743 ("Procedures" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4) 743 ("Procedures" "^\\s-*\\(?:create\\s-+\\(?:\\w+\\s-+\\)*\\)?proc\\(?:edure\\)?\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
744 ("Packages" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) 744 ("Packages" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*package\\s-+\\(?:body\\s-+\\)?\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
745 ("Types" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*type\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) 745 ("Types" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*type\\s-+\\(?:body\\s-+\\)?\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
746 ("Indexes" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*index\\s-+\\(\\w+\\)" 2) 746 ("Indexes" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*index\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1)
747 ("Tables/Views" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(table\\|view\\)\\s-+\\(\\w+\\)" 3)) 747 ("Tables/Views" "^\\s-*create\\s-+\\(?:\\w+\\s-+\\)*\\(?:table\\|view\\)\\s-+\\(?:if\\s-+not\\s-+exists\\s-+\\)?\\(\\w+\\)" 1))
748 "Define interesting points in the SQL buffer for `imenu'. 748 "Define interesting points in the SQL buffer for `imenu'.
749 749
750This is used to set `imenu-generic-expression' when SQL mode is 750This is used to set `imenu-generic-expression' when SQL mode is
@@ -1339,6 +1339,7 @@ Based on `comint-mode-map'.")
1339 "\\(?:\\w+\\s-+\\)*" ;; optional intervening keywords 1339 "\\(?:\\w+\\s-+\\)*" ;; optional intervening keywords
1340 "\\(?:table\\|view\\|\\(?:package\\|type\\)\\(?:\\s-+body\\)?\\|proc\\(?:edure\\)?" 1340 "\\(?:table\\|view\\|\\(?:package\\|type\\)\\(?:\\s-+body\\)?\\|proc\\(?:edure\\)?"
1341 "\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+" 1341 "\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+"
1342 "\\(?:if\\s-+not\\s-+exists\\s-+\\)?" ;; IF NOT EXISTS
1342 "\\(\\w+\\)") 1343 "\\(\\w+\\)")
1343 1 'font-lock-function-name-face)) 1344 1 'font-lock-function-name-face))
1344 1345