]> git.eshelyaron.com Git - emacs.git/commitdiff
Small executable.el fix related to bug#9879.
authorGlenn Morris <rgm@gnu.org>
Mon, 14 Nov 2011 02:14:01 +0000 (18:14 -0800)
committerGlenn Morris <rgm@gnu.org>
Mon, 14 Nov 2011 02:14:01 +0000 (18:14 -0800)
* lisp/progmodes/executable.el
(executable-make-buffer-file-executable-if-script-p):
Handle file-modes returning nil.

lisp/ChangeLog
lisp/progmodes/executable.el

index ea27df043f01f7b08c4515abcb93ee78280d2cff..65ab83e0204da12e6d4ddb3dbeda707634427c24 100644 (file)
@@ -1,5 +1,9 @@
 2011-11-14  Glenn Morris  <rgm@gnu.org>
 
+       * progmodes/executable.el
+       (executable-make-buffer-file-executable-if-script-p):
+       Handle file-modes returning nil.
+
        * mail/rmail.el (rmail-no-mail-p): Remove mode-line N/M indicator.
 
        * mail/rmailsum.el (rmail-summary, rmail-new-summary)
index d8133cb6b901326288384a540863c25d651574f8..281fa3cef728437c1f3a4468194e071e3b17d4cb 100644 (file)
@@ -268,12 +268,16 @@ file modes."
        (save-restriction
         (widen)
         (string= "#!" (buffer-substring (point-min) (+ 2 (point-min)))))
-       (let* ((current-mode (file-modes (buffer-file-name)))
-              (add-mode (logand ?\111 (default-file-modes))))
-         (or (/= (logand ?\111 current-mode) 0)
-             (zerop add-mode)
-             (set-file-modes (buffer-file-name)
-                             (logior current-mode add-mode))))))
+       (condition-case nil
+           (let* ((current-mode (file-modes (buffer-file-name)))
+                  (add-mode (logand ?\111 (default-file-modes))))
+             (or (/= (logand ?\111 current-mode) 0)
+                 (zerop add-mode)
+                 (set-file-modes (buffer-file-name)
+                                 (logior current-mode add-mode))))
+         ;; Eg file-modes can return nil (bug#9879).  It should not,
+         ;; in this context, but we should handle it all the same.
+         (error (message "Unable to make file executable")))))
 
 (provide 'executable)