diff options
| author | Stefan Monnier | 2012-11-19 16:30:55 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2012-11-19 16:30:55 -0500 |
| commit | 141462223d6f8063bf01692c2f41ecc58baea506 (patch) | |
| tree | 0b26028b48cc96f16ea3da59912c7408de01d66a | |
| parent | 1000d89524f28cc33341ae00c60ecc6994503f23 (diff) | |
| download | emacs-141462223d6f8063bf01692c2f41ecc58baea506.tar.gz emacs-141462223d6f8063bf01692c2f41ecc58baea506.zip | |
* lisp/emacs-lisp/byte-run.el (defun-declarations-alist):
Allow compiler-macros to be lambda expressions.
* lisp/progmodes/python.el: Use cl-lib. Move var declarations outside of
eval-when-compile.
(python-syntax-context): Add compiler-macro.
(python-font-lock-keywords): Simplify with De Morgan.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-run.el | 10 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 77 |
3 files changed, 60 insertions, 35 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index df0b8bd422f..ca585e0669f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2012-11-19 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-11-19 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/byte-run.el (defun-declarations-alist): | ||
| 4 | Allow a compiler-macro to be a lambda expression. | ||
| 5 | |||
| 6 | * progmodes/python.el: Use cl-lib. Move var declarations outside of | ||
| 7 | eval-when-compile. | ||
| 8 | (python-syntax-context): Add compiler-macro. | ||
| 9 | (python-font-lock-keywords): Simplify with De Morgan. | ||
| 10 | |||
| 3 | * vc/diff-mode.el (diff-hunk): Don't make useless timers. | 11 | * vc/diff-mode.el (diff-hunk): Don't make useless timers. |
| 4 | 12 | ||
| 5 | * files.el (load-file): Require match in minibuffer selection, as was | 13 | * files.el (load-file): Require match in minibuffer selection, as was |
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 462b4a25154..06f404d615c 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el | |||
| @@ -81,8 +81,14 @@ The return value of this function is not used." | |||
| 81 | #'(lambda (f _args new-name when) | 81 | #'(lambda (f _args new-name when) |
| 82 | `(make-obsolete ',f ',new-name ,when))) | 82 | `(make-obsolete ',f ',new-name ,when))) |
| 83 | (list 'compiler-macro | 83 | (list 'compiler-macro |
| 84 | #'(lambda (f _args compiler-function) | 84 | #'(lambda (f args compiler-function) |
| 85 | `(put ',f 'compiler-macro #',compiler-function))) | 85 | ;; FIXME: Make it possible to just reuse `args'. |
| 86 | `(eval-and-compile | ||
| 87 | (put ',f 'compiler-macro | ||
| 88 | ,(if (eq (car-safe compiler-function) 'lambda) | ||
| 89 | `(lambda ,(append (cadr compiler-function) args) | ||
| 90 | ,@(cddr compiler-function)) | ||
| 91 | #',compiler-function))))) | ||
| 86 | (list 'doc-string | 92 | (list 'doc-string |
| 87 | #'(lambda (f _args pos) | 93 | #'(lambda (f _args pos) |
| 88 | (list 'put (list 'quote f) ''doc-string-elt (list 'quote pos)))) | 94 | (list 'put (list 'quote f) ''doc-string-elt (list 'quote pos)))) |
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. |
| 365 | TYPE can be `comment', `string' or `paren'. It returns the start | 364 | TYPE can be `comment', `string' or `paren'. It returns the start |
| 366 | character address of the specified TYPE." | 365 | character 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 |