diff options
| author | Stefan Monnier | 2013-09-04 23:46:34 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-09-04 23:46:34 -0400 |
| commit | c0458e0b21bf507b6a9273189c58a6b97efa2db2 (patch) | |
| tree | 95213e4e50168354bcc87c901d98bf9976ba1db1 | |
| parent | 6c42fc3efbbf590fca00b866859fbfa13d34b70a (diff) | |
| download | emacs-c0458e0b21bf507b6a9273189c58a6b97efa2db2.tar.gz emacs-c0458e0b21bf507b6a9273189c58a6b97efa2db2.zip | |
* lisp/subr.el (pop): Use `car-safe'.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Remove hack
to detect unused `pop' return value.
* lisp/emacs-lisp/advice.el (defadvice): Add indent rule.
* lisp/international/mule-cmds.el: Require CL.
(find-coding-systems-for-charsets): Avoid add-to-list.
(sanitize-coding-system-list): New function, extracted from
select-safe-coding-system-interactively.
(select-safe-coding-system-interactively): Use it.
(read-input-method-name): Accept symbols for `default'.
* lisp/progmodes/python.el (python-nav-beginning-of-block): Remove unused
var `block-regexp'.
(python-nav--forward-sexp): Remove unused var `re-search-fn'.
(python-fill-string): Remove unused var `marker'.
(python-skeleton-add-menu-items): Remove unused var `items'.
| -rw-r--r-- | lisp/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/emacs-lisp/advice.el | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 12 | ||||
| -rw-r--r-- | lisp/international/mule-cmds.el | 68 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 23 | ||||
| -rw-r--r-- | lisp/subr.el | 16 |
6 files changed, 77 insertions, 65 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9619f9fc865..527f363362f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2013-09-05 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * subr.el (pop): Use `car-safe'. | ||
| 4 | * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Remove hack | ||
| 5 | to detect unused `pop' return value. | ||
| 6 | |||
| 7 | * progmodes/python.el (python-nav-beginning-of-block): Remove unused | ||
| 8 | var `block-regexp'. | ||
| 9 | (python-nav--forward-sexp): Remove unused var `re-search-fn'. | ||
| 10 | (python-fill-string): Remove unused var `marker'. | ||
| 11 | (python-skeleton-add-menu-items): Remove unused var `items'. | ||
| 12 | |||
| 13 | * international/mule-cmds.el: Require CL. | ||
| 14 | (find-coding-systems-for-charsets): Avoid add-to-list. | ||
| 15 | (sanitize-coding-system-list): New function, extracted from | ||
| 16 | select-safe-coding-system-interactively. | ||
| 17 | (select-safe-coding-system-interactively): Use it. | ||
| 18 | (read-input-method-name): Accept symbols for `default'. | ||
| 19 | |||
| 20 | * emacs-lisp/advice.el (defadvice): Add indent rule. | ||
| 21 | |||
| 1 | 2013-09-05 Daniel Hackney <dan@haxney.org> | 22 | 2013-09-05 Daniel Hackney <dan@haxney.org> |
| 2 | 23 | ||
| 3 | * dired-x.el: | 24 | * dired-x.el: |
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el index 861054e777f..7996f9a2263 100644 --- a/lisp/emacs-lisp/advice.el +++ b/lisp/emacs-lisp/advice.el | |||
| @@ -3190,7 +3190,7 @@ See Info node `(elisp)Advising Functions' for comprehensive documentation. | |||
| 3190 | usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...) | 3190 | usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...) |
| 3191 | [DOCSTRING] [INTERACTIVE-FORM] | 3191 | [DOCSTRING] [INTERACTIVE-FORM] |
| 3192 | BODY...)" | 3192 | BODY...)" |
| 3193 | (declare (doc-string 3) | 3193 | (declare (doc-string 3) (indent 2) |
| 3194 | (debug (&define name ;; thing being advised. | 3194 | (debug (&define name ;; thing being advised. |
| 3195 | (name ;; class is [&or "before" "around" "after" | 3195 | (name ;; class is [&or "before" "around" "after" |
| 3196 | ;; "activation" "deactivation"] | 3196 | ;; "activation" "deactivation"] |
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 7214501362d..9da1a4d1f38 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -533,18 +533,6 @@ | |||
| 533 | ((and for-effect (setq tmp (get fn 'side-effect-free)) | 533 | ((and for-effect (setq tmp (get fn 'side-effect-free)) |
| 534 | (or byte-compile-delete-errors | 534 | (or byte-compile-delete-errors |
| 535 | (eq tmp 'error-free) | 535 | (eq tmp 'error-free) |
| 536 | ;; Detect the expansion of (pop foo). | ||
| 537 | ;; There is no need to compile the call to `car' there. | ||
| 538 | (and (eq fn 'car) | ||
| 539 | (eq (car-safe (cadr form)) 'prog1) | ||
| 540 | (let ((var (cadr (cadr form))) | ||
| 541 | (last (nth 2 (cadr form)))) | ||
| 542 | (and (symbolp var) | ||
| 543 | (null (nthcdr 3 (cadr form))) | ||
| 544 | (eq (car-safe last) 'setq) | ||
| 545 | (eq (cadr last) var) | ||
| 546 | (eq (car-safe (nth 2 last)) 'cdr) | ||
| 547 | (eq (cadr (nth 2 last)) var)))) | ||
| 548 | (progn | 536 | (progn |
| 549 | (byte-compile-warn "value returned from %s is unused" | 537 | (byte-compile-warn "value returned from %s is unused" |
| 550 | (prin1-to-string form)) | 538 | (prin1-to-string form)) |
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 34b1576d23e..588460b657b 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -30,6 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (eval-when-compile (require 'cl-lib)) | ||
| 34 | |||
| 33 | (defvar dos-codepage) | 35 | (defvar dos-codepage) |
| 34 | (autoload 'widget-value "wid-edit") | 36 | (autoload 'widget-value "wid-edit") |
| 35 | 37 | ||
| @@ -548,7 +550,7 @@ Emacs, but is unlikely to be what you really want now." | |||
| 548 | (coding-system-charset-list cs))) | 550 | (coding-system-charset-list cs))) |
| 549 | (charsets charsets)) | 551 | (charsets charsets)) |
| 550 | (if (coding-system-get cs :ascii-compatible-p) | 552 | (if (coding-system-get cs :ascii-compatible-p) |
| 551 | (add-to-list 'cs-charsets 'ascii)) | 553 | (cl-pushnew 'ascii cs-charsets)) |
| 552 | (if (catch 'ok | 554 | (if (catch 'ok |
| 553 | (when cs-charsets | 555 | (when cs-charsets |
| 554 | (while charsets | 556 | (while charsets |
| @@ -636,6 +638,36 @@ The meaning is the same as the argument ACCEPT-DEFAULT-P of the | |||
| 636 | function `select-safe-coding-system' (which see). This variable | 638 | function `select-safe-coding-system' (which see). This variable |
| 637 | overrides that argument.") | 639 | overrides that argument.") |
| 638 | 640 | ||
| 641 | (defun sanitize-coding-system-list (codings) | ||
| 642 | "Return a list of coding systems presumably more user-friendly than CODINGS." | ||
| 643 | ;; Change each safe coding system to the corresponding | ||
| 644 | ;; mime-charset name if it is also a coding system. Such a name | ||
| 645 | ;; is more friendly to users. | ||
| 646 | (setq codings | ||
| 647 | (mapcar (lambda (cs) | ||
| 648 | (let ((mime-charset (coding-system-get cs 'mime-charset))) | ||
| 649 | (if (and mime-charset (coding-system-p mime-charset) | ||
| 650 | (coding-system-equal cs mime-charset)) | ||
| 651 | mime-charset cs))) | ||
| 652 | codings)) | ||
| 653 | |||
| 654 | ;; Don't offer variations with locking shift, which you | ||
| 655 | ;; basically never want. | ||
| 656 | (let (l) | ||
| 657 | (dolist (elt codings (setq codings (nreverse l))) | ||
| 658 | (unless (or (eq 'coding-category-iso-7-else | ||
| 659 | (coding-system-category elt)) | ||
| 660 | (eq 'coding-category-iso-8-else | ||
| 661 | (coding-system-category elt))) | ||
| 662 | (push elt l)))) | ||
| 663 | |||
| 664 | ;; Remove raw-text, emacs-mule and no-conversion unless nothing | ||
| 665 | ;; else is available. | ||
| 666 | (or (delq 'raw-text | ||
| 667 | (delq 'emacs-mule | ||
| 668 | (delq 'no-conversion (copy-sequence codings)))) | ||
| 669 | codings)) | ||
| 670 | |||
| 639 | (defun select-safe-coding-system-interactively (from to codings unsafe | 671 | (defun select-safe-coding-system-interactively (from to codings unsafe |
| 640 | &optional rejected default) | 672 | &optional rejected default) |
| 641 | "Select interactively a coding system for the region FROM ... TO. | 673 | "Select interactively a coding system for the region FROM ... TO. |
| @@ -667,35 +699,7 @@ DEFAULT is the coding system to use by default in the query." | |||
| 667 | from to coding 11))))) | 699 | from to coding 11))))) |
| 668 | unsafe))) | 700 | unsafe))) |
| 669 | 701 | ||
| 670 | ;; Change each safe coding system to the corresponding | 702 | (setq codings (sanitize-coding-system-list codings)) |
| 671 | ;; mime-charset name if it is also a coding system. Such a name | ||
| 672 | ;; is more friendly to users. | ||
| 673 | (let ((l codings) | ||
| 674 | mime-charset) | ||
| 675 | (while l | ||
| 676 | (setq mime-charset (coding-system-get (car l) :mime-charset)) | ||
| 677 | (if (and mime-charset (coding-system-p mime-charset) | ||
| 678 | (coding-system-equal (car l) mime-charset)) | ||
| 679 | (setcar l mime-charset)) | ||
| 680 | (setq l (cdr l)))) | ||
| 681 | |||
| 682 | ;; Don't offer variations with locking shift, which you | ||
| 683 | ;; basically never want. | ||
| 684 | (let (l) | ||
| 685 | (dolist (elt codings (setq codings (nreverse l))) | ||
| 686 | (unless (or (eq 'coding-category-iso-7-else | ||
| 687 | (coding-system-category elt)) | ||
| 688 | (eq 'coding-category-iso-8-else | ||
| 689 | (coding-system-category elt))) | ||
| 690 | (push elt l)))) | ||
| 691 | |||
| 692 | ;; Remove raw-text, emacs-mule and no-conversion unless nothing | ||
| 693 | ;; else is available. | ||
| 694 | (setq codings | ||
| 695 | (or (delq 'raw-text | ||
| 696 | (delq 'emacs-mule | ||
| 697 | (delq 'no-conversion codings))) | ||
| 698 | '(raw-text emacs-mule no-conversion))) | ||
| 699 | 703 | ||
| 700 | (let ((window-configuration (current-window-configuration)) | 704 | (let ((window-configuration (current-window-configuration)) |
| 701 | (bufname (buffer-name)) | 705 | (bufname (buffer-name)) |
| @@ -1421,7 +1425,9 @@ The return value is a string." | |||
| 1421 | ;; buffer local. | 1425 | ;; buffer local. |
| 1422 | (input-method (completing-read prompt input-method-alist | 1426 | (input-method (completing-read prompt input-method-alist |
| 1423 | nil t nil 'input-method-history | 1427 | nil t nil 'input-method-history |
| 1424 | default))) | 1428 | (if (and default (symbolp default)) |
| 1429 | (symbol-name default) | ||
| 1430 | default)))) | ||
| 1425 | (if (and input-method (symbolp input-method)) | 1431 | (if (and input-method (symbolp input-method)) |
| 1426 | (setq input-method (symbol-name input-method))) | 1432 | (setq input-method (symbol-name input-method))) |
| 1427 | (if (> (length input-method) 0) | 1433 | (if (> (length input-method) 0) |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index fb2dc01c9be..be151bf8114 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1327,9 +1327,7 @@ backward to previous statement." | |||
| 1327 | (defun python-nav-beginning-of-block () | 1327 | (defun python-nav-beginning-of-block () |
| 1328 | "Move to start of current block." | 1328 | "Move to start of current block." |
| 1329 | (interactive "^") | 1329 | (interactive "^") |
| 1330 | (let ((starting-pos (point)) | 1330 | (let ((starting-pos (point))) |
| 1331 | (block-regexp (python-rx | ||
| 1332 | line-start (* whitespace) block-start))) | ||
| 1333 | (if (progn | 1331 | (if (progn |
| 1334 | (python-nav-beginning-of-statement) | 1332 | (python-nav-beginning-of-statement) |
| 1335 | (looking-at (python-rx block-start))) | 1333 | (looking-at (python-rx block-start))) |
| @@ -1422,9 +1420,6 @@ backwards." | |||
| 1422 | (let* ((forward-p (if (> dir 0) | 1420 | (let* ((forward-p (if (> dir 0) |
| 1423 | (and (setq dir 1) t) | 1421 | (and (setq dir 1) t) |
| 1424 | (and (setq dir -1) nil))) | 1422 | (and (setq dir -1) nil))) |
| 1425 | (re-search-fn (if forward-p | ||
| 1426 | 're-search-forward | ||
| 1427 | 're-search-backward)) | ||
| 1428 | (context-type (python-syntax-context-type))) | 1423 | (context-type (python-syntax-context-type))) |
| 1429 | (cond | 1424 | (cond |
| 1430 | ((memq context-type '(string comment)) | 1425 | ((memq context-type '(string comment)) |
| @@ -2666,8 +2661,7 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." | |||
| 2666 | (defun python-fill-string (&optional justify) | 2661 | (defun python-fill-string (&optional justify) |
| 2667 | "String fill function for `python-fill-paragraph'. | 2662 | "String fill function for `python-fill-paragraph'. |
| 2668 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." | 2663 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." |
| 2669 | (let* ((marker (point-marker)) | 2664 | (let* ((str-start-pos |
| 2670 | (str-start-pos | ||
| 2671 | (set-marker | 2665 | (set-marker |
| 2672 | (make-marker) | 2666 | (make-marker) |
| 2673 | (or (python-syntax-context 'string) | 2667 | (or (python-syntax-context 'string) |
| @@ -2733,7 +2727,7 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." | |||
| 2733 | ;; Again indent only if a newline is added. | 2727 | ;; Again indent only if a newline is added. |
| 2734 | (indent-according-to-mode))))) t) | 2728 | (indent-according-to-mode))))) t) |
| 2735 | 2729 | ||
| 2736 | (defun python-fill-decorator (&optional justify) | 2730 | (defun python-fill-decorator (&optional _justify) |
| 2737 | "Decorator fill function for `python-fill-paragraph'. | 2731 | "Decorator fill function for `python-fill-paragraph'. |
| 2738 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." | 2732 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." |
| 2739 | t) | 2733 | t) |
| @@ -2895,8 +2889,7 @@ The skeleton will be bound to python-skeleton-NAME." | |||
| 2895 | 2889 | ||
| 2896 | (defun python-skeleton-add-menu-items () | 2890 | (defun python-skeleton-add-menu-items () |
| 2897 | "Add menu items to Python->Skeletons menu." | 2891 | "Add menu items to Python->Skeletons menu." |
| 2898 | (let ((skeletons (sort python-skeleton-available 'string<)) | 2892 | (let ((skeletons (sort python-skeleton-available 'string<))) |
| 2899 | (items)) | ||
| 2900 | (dolist (skeleton skeletons) | 2893 | (dolist (skeleton skeletons) |
| 2901 | (easy-menu-add-item | 2894 | (easy-menu-add-item |
| 2902 | nil '("Python" "Skeletons") | 2895 | nil '("Python" "Skeletons") |
| @@ -2984,7 +2977,7 @@ Runs COMMAND, a shell command, as if by `compile'. See | |||
| 2984 | (let ((process-environment (python-shell-calculate-process-environment)) | 2977 | (let ((process-environment (python-shell-calculate-process-environment)) |
| 2985 | (exec-path (python-shell-calculate-exec-path))) | 2978 | (exec-path (python-shell-calculate-exec-path))) |
| 2986 | (compilation-start command nil | 2979 | (compilation-start command nil |
| 2987 | (lambda (mode-name) | 2980 | (lambda (_modename) |
| 2988 | (format python-check-buffer-name command))))) | 2981 | (format python-check-buffer-name command))))) |
| 2989 | 2982 | ||
| 2990 | 2983 | ||
| @@ -3095,7 +3088,7 @@ It must be a function with two arguments: TYPE and NAME.") | |||
| 3095 | "Return imenu label for parent node using TYPE and NAME." | 3088 | "Return imenu label for parent node using TYPE and NAME." |
| 3096 | (format "%s..." (python-imenu-format-item-label type name))) | 3089 | (format "%s..." (python-imenu-format-item-label type name))) |
| 3097 | 3090 | ||
| 3098 | (defun python-imenu-format-parent-item-jump-label (type name) | 3091 | (defun python-imenu-format-parent-item-jump-label (type _name) |
| 3099 | "Return imenu label for parent node jump using TYPE and NAME." | 3092 | "Return imenu label for parent node jump using TYPE and NAME." |
| 3100 | (if (string= type "class") | 3093 | (if (string= type "class") |
| 3101 | "*class definition*" | 3094 | "*class definition*" |
| @@ -3209,7 +3202,7 @@ To this: | |||
| 3209 | (cons name (cdar pos)) | 3202 | (cons name (cdar pos)) |
| 3210 | (python-imenu-create-flat-index (cddr item) name)))))) | 3203 | (python-imenu-create-flat-index (cddr item) name)))))) |
| 3211 | (or alist | 3204 | (or alist |
| 3212 | (let* ((fn (lambda (type name) name)) | 3205 | (let* ((fn (lambda (_type name) name)) |
| 3213 | (python-imenu-format-item-label-function fn) | 3206 | (python-imenu-format-item-label-function fn) |
| 3214 | (python-imenu-format-parent-item-label-function fn) | 3207 | (python-imenu-format-parent-item-label-function fn) |
| 3215 | (python-imenu-format-parent-item-jump-label-function fn)) | 3208 | (python-imenu-format-parent-item-jump-label-function fn)) |
| @@ -3614,7 +3607,7 @@ if that value is non-nil." | |||
| 3614 | 3607 | ||
| 3615 | (add-to-list 'hs-special-modes-alist | 3608 | (add-to-list 'hs-special-modes-alist |
| 3616 | `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" | 3609 | `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" |
| 3617 | ,(lambda (arg) | 3610 | ,(lambda (_arg) |
| 3618 | (python-nav-end-of-defun)) nil)) | 3611 | (python-nav-end-of-defun)) nil)) |
| 3619 | 3612 | ||
| 3620 | (set (make-local-variable 'mode-require-final-newline) t) | 3613 | (set (make-local-variable 'mode-require-final-newline) t) |
diff --git a/lisp/subr.el b/lisp/subr.el index b8b0d5af3b8..0a28d4778d4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -170,12 +170,16 @@ PLACE must be a generalized variable whose value is a list. | |||
| 170 | If the value is nil, `pop' returns nil but does not actually | 170 | If the value is nil, `pop' returns nil but does not actually |
| 171 | change the list." | 171 | change the list." |
| 172 | (declare (debug (gv-place))) | 172 | (declare (debug (gv-place))) |
| 173 | (list 'car | 173 | ;; We use `car-safe' here instead of `car' because the behavior is the same |
| 174 | (if (symbolp place) | 174 | ;; (if it's not a cons cell, the `cdr' would have signaled an error already), |
| 175 | ;; So we can use `pop' in the bootstrap before `gv' can be used. | 175 | ;; but `car-safe' is total, so the byte-compiler can safely remove it if the |
| 176 | (list 'prog1 place (list 'setq place (list 'cdr place))) | 176 | ;; result is not used. |
| 177 | (gv-letplace (getter setter) place | 177 | `(car-safe |
| 178 | `(prog1 ,getter ,(funcall setter `(cdr ,getter))))))) | 178 | ,(if (symbolp place) |
| 179 | ;; So we can use `pop' in the bootstrap before `gv' can be used. | ||
| 180 | (list 'prog1 place (list 'setq place (list 'cdr place))) | ||
| 181 | (gv-letplace (getter setter) place | ||
| 182 | `(prog1 ,getter ,(funcall setter `(cdr ,getter))))))) | ||
| 179 | 183 | ||
| 180 | (defmacro when (cond &rest body) | 184 | (defmacro when (cond &rest body) |
| 181 | "If COND yields non-nil, do BODY, else return nil. | 185 | "If COND yields non-nil, do BODY, else return nil. |