From 56632ce4cd8616f0613e8734d62ec5e2f833c7dc Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 13 Nov 2011 18:14:01 -0800 Subject: [PATCH] Small executable.el fix related to bug#9879. * lisp/progmodes/executable.el (executable-make-buffer-file-executable-if-script-p): Handle file-modes returning nil. --- lisp/ChangeLog | 4 ++++ lisp/progmodes/executable.el | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ea27df043f0..65ab83e0204 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2011-11-14 Glenn Morris + * 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) diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el index d8133cb6b90..281fa3cef72 100644 --- a/lisp/progmodes/executable.el +++ b/lisp/progmodes/executable.el @@ -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) -- 2.39.2