emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114139: * lisp/subr.el (pop): Use `car-safe'.


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r114139: * lisp/subr.el (pop): Use `car-safe'.
Date: Thu, 05 Sep 2013 03:46:41 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114139
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-09-04 23:46:34 -0400
message:
  * 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'.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/advice.el      advice.el-20091113204419-o5vbwnq5f7feedwu-605
  lisp/emacs-lisp/byte-opt.el    byteopt.el-20091113204419-o5vbwnq5f7feedwu-491
  lisp/international/mule-cmds.el 
mulecmds.el-20091113204419-o5vbwnq5f7feedwu-1043
  lisp/progmodes/python.el       python.el-20091113204419-o5vbwnq5f7feedwu-3008
  lisp/subr.el                   subr.el-20091113204419-o5vbwnq5f7feedwu-151
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-09-05 03:30:07 +0000
+++ b/lisp/ChangeLog    2013-09-05 03:46:34 +0000
@@ -1,3 +1,24 @@
+2013-09-05  Stefan Monnier  <address@hidden>
+
+       * subr.el (pop): Use `car-safe'.
+       * emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Remove hack
+       to detect unused `pop' return value.
+
+       * 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'.
+
+       * 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'.
+
+       * emacs-lisp/advice.el (defadvice): Add indent rule.
+
 2013-09-05  Daniel Hackney  <address@hidden>
 
        * dired-x.el:

=== modified file 'lisp/emacs-lisp/advice.el'
--- a/lisp/emacs-lisp/advice.el 2013-08-04 20:18:11 +0000
+++ b/lisp/emacs-lisp/advice.el 2013-09-05 03:46:34 +0000
@@ -3190,7 +3190,7 @@
 usage: (defadvice FUNCTION (CLASS NAME [POSITION] [ARGLIST] FLAG...)
           [DOCSTRING] [INTERACTIVE-FORM]
           BODY...)"
-  (declare (doc-string 3)
+  (declare (doc-string 3) (indent 2)
            (debug (&define name  ;; thing being advised.
                            (name ;; class is [&or "before" "around" "after"
                                  ;;               "activation" "deactivation"]

=== modified file 'lisp/emacs-lisp/byte-opt.el'
--- a/lisp/emacs-lisp/byte-opt.el       2013-06-14 02:31:28 +0000
+++ b/lisp/emacs-lisp/byte-opt.el       2013-09-05 03:46:34 +0000
@@ -533,18 +533,6 @@
          ((and for-effect (setq tmp (get fn 'side-effect-free))
                (or byte-compile-delete-errors
                    (eq tmp 'error-free)
-                   ;; Detect the expansion of (pop foo).
-                   ;; There is no need to compile the call to `car' there.
-                   (and (eq fn 'car)
-                        (eq (car-safe (cadr form)) 'prog1)
-                        (let ((var (cadr (cadr form)))
-                              (last (nth 2 (cadr form))))
-                          (and (symbolp var)
-                               (null (nthcdr 3 (cadr form)))
-                               (eq (car-safe last) 'setq)
-                               (eq (cadr last) var)
-                               (eq (car-safe (nth 2 last)) 'cdr)
-                               (eq (cadr (nth 2 last)) var))))
                    (progn
                      (byte-compile-warn "value returned from %s is unused"
                                         (prin1-to-string form))

=== modified file 'lisp/international/mule-cmds.el'
--- a/lisp/international/mule-cmds.el   2013-08-08 23:59:14 +0000
+++ b/lisp/international/mule-cmds.el   2013-09-05 03:46:34 +0000
@@ -30,6 +30,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defvar dos-codepage)
 (autoload 'widget-value "wid-edit")
 
@@ -548,7 +550,7 @@
                                     (coding-system-charset-list cs)))
                   (charsets charsets))
               (if (coding-system-get cs :ascii-compatible-p)
-                  (add-to-list 'cs-charsets 'ascii))
+                  (cl-pushnew 'ascii cs-charsets))
               (if (catch 'ok
                     (when cs-charsets
                       (while charsets
@@ -636,6 +638,36 @@
 function `select-safe-coding-system' (which see).  This variable
 overrides that argument.")
 
+(defun sanitize-coding-system-list (codings)
+  "Return a list of coding systems presumably more user-friendly than CODINGS."
+  ;; Change each safe coding system to the corresponding
+  ;; mime-charset name if it is also a coding system.  Such a name
+  ;; is more friendly to users.
+  (setq codings
+        (mapcar (lambda (cs)
+                  (let ((mime-charset (coding-system-get cs 'mime-charset)))
+                    (if (and mime-charset (coding-system-p mime-charset)
+                             (coding-system-equal cs mime-charset))
+                        mime-charset cs)))
+                codings))
+
+  ;; Don't offer variations with locking shift, which you
+  ;; basically never want.
+  (let (l)
+    (dolist (elt codings (setq codings (nreverse l)))
+      (unless (or (eq 'coding-category-iso-7-else
+                     (coding-system-category elt))
+                 (eq 'coding-category-iso-8-else
+                     (coding-system-category elt)))
+       (push elt l))))
+
+  ;; Remove raw-text, emacs-mule and no-conversion unless nothing
+  ;; else is available.
+  (or (delq 'raw-text
+            (delq 'emacs-mule
+                  (delq 'no-conversion (copy-sequence codings))))
+      codings))
+
 (defun select-safe-coding-system-interactively (from to codings unsafe
                                                &optional rejected default)
   "Select interactively a coding system for the region FROM ... TO.
@@ -667,35 +699,7 @@
                                         from to coding 11)))))
                    unsafe)))
 
-  ;; Change each safe coding system to the corresponding
-  ;; mime-charset name if it is also a coding system.  Such a name
-  ;; is more friendly to users.
-  (let ((l codings)
-       mime-charset)
-    (while l
-      (setq mime-charset (coding-system-get (car l) :mime-charset))
-      (if (and mime-charset (coding-system-p mime-charset)
-              (coding-system-equal (car l) mime-charset))
-         (setcar l mime-charset))
-      (setq l (cdr l))))
-
-  ;; Don't offer variations with locking shift, which you
-  ;; basically never want.
-  (let (l)
-    (dolist (elt codings (setq codings (nreverse l)))
-      (unless (or (eq 'coding-category-iso-7-else
-                     (coding-system-category elt))
-                 (eq 'coding-category-iso-8-else
-                     (coding-system-category elt)))
-       (push elt l))))
-
-  ;; Remove raw-text, emacs-mule and no-conversion unless nothing
-  ;; else is available.
-  (setq codings
-       (or (delq 'raw-text
-                 (delq 'emacs-mule
-                       (delq 'no-conversion codings)))
-           '(raw-text emacs-mule no-conversion)))
+  (setq codings (sanitize-coding-system-list codings))
 
   (let ((window-configuration (current-window-configuration))
        (bufname (buffer-name))
@@ -1421,7 +1425,9 @@
         ;; buffer local.
         (input-method (completing-read prompt input-method-alist
                                        nil t nil 'input-method-history
-                                       default)))
+                                       (if (and default (symbolp default))
+                                            (symbol-name default)
+                                          default))))
     (if (and input-method (symbolp input-method))
        (setq input-method (symbol-name input-method)))
     (if (> (length input-method) 0)

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2013-09-02 13:56:03 +0000
+++ b/lisp/progmodes/python.el  2013-09-05 03:46:34 +0000
@@ -1327,9 +1327,7 @@
 (defun python-nav-beginning-of-block ()
   "Move to start of current block."
   (interactive "^")
-  (let ((starting-pos (point))
-        (block-regexp (python-rx
-                       line-start (* whitespace) block-start)))
+  (let ((starting-pos (point)))
     (if (progn
           (python-nav-beginning-of-statement)
           (looking-at (python-rx block-start)))
@@ -1422,9 +1420,6 @@
     (let* ((forward-p (if (> dir 0)
                           (and (setq dir 1) t)
                         (and (setq dir -1) nil)))
-           (re-search-fn (if forward-p
-                             're-search-forward
-                           're-search-backward))
            (context-type (python-syntax-context-type)))
       (cond
        ((memq context-type '(string comment))
@@ -2666,8 +2661,7 @@
 (defun python-fill-string (&optional justify)
   "String fill function for `python-fill-paragraph'.
 JUSTIFY should be used (if applicable) as in `fill-paragraph'."
-  (let* ((marker (point-marker))
-         (str-start-pos
+  (let* ((str-start-pos
           (set-marker
            (make-marker)
            (or (python-syntax-context 'string)
@@ -2733,7 +2727,7 @@
              ;; Again indent only if a newline is added.
              (indent-according-to-mode))))) t)
 
-(defun python-fill-decorator (&optional justify)
+(defun python-fill-decorator (&optional _justify)
   "Decorator fill function for `python-fill-paragraph'.
 JUSTIFY should be used (if applicable) as in `fill-paragraph'."
   t)
@@ -2895,8 +2889,7 @@
 
 (defun python-skeleton-add-menu-items ()
   "Add menu items to Python->Skeletons menu."
-  (let ((skeletons (sort python-skeleton-available 'string<))
-        (items))
+  (let ((skeletons (sort python-skeleton-available 'string<)))
     (dolist (skeleton skeletons)
       (easy-menu-add-item
        nil '("Python" "Skeletons")
@@ -2984,7 +2977,7 @@
   (let ((process-environment (python-shell-calculate-process-environment))
         (exec-path (python-shell-calculate-exec-path)))
     (compilation-start command nil
-                       (lambda (mode-name)
+                       (lambda (_modename)
                          (format python-check-buffer-name command)))))
 
 
@@ -3095,7 +3088,7 @@
   "Return imenu label for parent node using TYPE and NAME."
   (format "%s..." (python-imenu-format-item-label type name)))
 
-(defun python-imenu-format-parent-item-jump-label (type name)
+(defun python-imenu-format-parent-item-jump-label (type _name)
   "Return imenu label for parent node jump using TYPE and NAME."
   (if (string= type "class")
       "*class definition*"
@@ -3209,7 +3202,7 @@
                 (cons name (cdar pos))
                 (python-imenu-create-flat-index (cddr item) name))))))
     (or alist
-        (let* ((fn (lambda (type name) name))
+        (let* ((fn (lambda (_type name) name))
                (python-imenu-format-item-label-function fn)
               (python-imenu-format-parent-item-label-function fn)
               (python-imenu-format-parent-item-jump-label-function fn))
@@ -3614,7 +3607,7 @@
 
   (add-to-list 'hs-special-modes-alist
                `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
-                             ,(lambda (arg)
+                             ,(lambda (_arg)
                                 (python-nav-end-of-defun)) nil))
 
   (set (make-local-variable 'mode-require-final-newline) t)

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2013-08-09 21:22:44 +0000
+++ b/lisp/subr.el      2013-09-05 03:46:34 +0000
@@ -170,12 +170,16 @@
 If the value is nil, `pop' returns nil but does not actually
 change the list."
   (declare (debug (gv-place)))
-  (list 'car
-        (if (symbolp place)
-            ;; So we can use `pop' in the bootstrap before `gv' can be used.
-            (list 'prog1 place (list 'setq place (list 'cdr place)))
-          (gv-letplace (getter setter) place
-            `(prog1 ,getter ,(funcall setter `(cdr ,getter)))))))
+  ;; We use `car-safe' here instead of `car' because the behavior is the same
+  ;; (if it's not a cons cell, the `cdr' would have signaled an error already),
+  ;; but `car-safe' is total, so the byte-compiler can safely remove it if the
+  ;; result is not used.
+  `(car-safe
+    ,(if (symbolp place)
+         ;; So we can use `pop' in the bootstrap before `gv' can be used.
+         (list 'prog1 place (list 'setq place (list 'cdr place)))
+       (gv-letplace (getter setter) place
+         `(prog1 ,getter ,(funcall setter `(cdr ,getter)))))))
 
 (defmacro when (cond &rest body)
   "If COND yields non-nil, do BODY, else return nil.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]