* bug#18915: 24.3; Feature: Prompt to make executable on write-file
@ 2014-10-31 18:01 Ed Avis
2014-10-31 18:06 ` Glenn Morris
2014-10-31 21:16 ` Stefan Monnier
0 siblings, 2 replies; 7+ messages in thread
From: Ed Avis @ 2014-10-31 18:01 UTC (permalink / raw)
To: 18915
This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org. Please check that
the From: line contains a valid email address. After a delay of up
to one day, you should receive an acknowledgment at that address.
Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.
Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug. If you can, give a recipe
starting from `emacs -Q':
On Unix, Create a file with execute permission (chmod a+x file)
and open it with C-x C-f file RET. Now save that as a different
file, C-x C-w otherfile RET.
Current behaviour: a file called otherfile is written but it is not
executable, even though the file that you originally visited was.
It would be useful if Emacs on write-file would first write the
new file, and then (only if that involved creating the new file,
and only if the buffer was previously visiting an executable file)
prompt for whether to make the newly written file executable.
I suggest that most of the time, the user will probably want to
make the new file executable (if you edit a script and save a
copy, you'll probably want to run the new script). However,
making things executable by default is a bit dangerous, so
better to prompt.
If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
`bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/share/emacs/24.3/etc/DEBUG.
In GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9)
of 2014-09-30 on buildvm-10.phx2.fedoraproject.org
Configured using:
`configure '--build=x86_64-redhat-linux-gnu'
'--host=x86_64-redhat-linux-gnu' '--program-prefix='
'--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
'--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib64' '--libexecdir=/usr/libexec'
'--localstatedir=/var' '--sharedstatedir=/var/lib'
'--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus'
'--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff'
'--with-xft' '--with-xpm' '--with-x-toolkit=gtk3' '--with-gpm=no'
'build_alias=x86_64-redhat-linux-gnu'
'host_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''
Important settings:
value of $LC_COLLATE: C
value of $LC_CTYPE: en_GB.UTF-8
value of $LC_MESSAGES: en_GB.UTF-8
value of $LC_MONETARY: en_GB.UTF-8
value of $LC_NUMERIC: en_GB.UTF-8
value of $LC_TIME: en_GB.UTF-8
value of $LANG: en_GB.UTF-8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Help
Minor modes in effect:
diff-auto-refine-mode: t
shell-dirtrack-mode: t
tooltip-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Recent input:
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s
C-a C-x C-w t e s t C-a C-k / v a r TAB q w TAB DEL
DEL w TAB c g TAB t e s t _ c a DEL DEL DEL / c a p
TAB i t a l _ a l l o c a t i o n RET ESC x s h e l
l RET ESC > w c DEL DEL e c h o SPC ; DEL ' c a p i
t a l _ a l l o c a t i o n ? f u n d _ g r o u p _
i d = 0 ' SPC | SPC . / m i s TAB t e s t _ p a TAB
RET C-x 2 C-x o C-x b c a p TAB RET C-x C-f / v a r
TAB C-g C-x k RET C-x C-f / v a r TAB w TAB C-g ESC
! C-g c j m DEL DEL h m o d SPC a + x SPC / v a r TAB
w TAB c g TAB t e s t / c a p TAB RET C-h k C-x C-w
c a p i t a l _ a l l o c a t i o n ? f u n d _ g r
o u p _ i d = 0 C-g C-g ESC x e m a c s - b u TAB g
RET DEL DEL DEL DEL DEL DEL DEL DEL DEL DEL DEL r e
p o r t - e m TAB RET
Recent messages:
Mark set
Mark saved where search started [3 times]
Saving file /var/www/cgi-bin/test/capital_allocation...
Wrote /var/www/cgi-bin/test/capital_allocation
Mark set
Quit [3 times]
Type "q" to delete help window.
Quit [2 times]
delete-backward-char: Text is read-only [2 times]
Load-path shadows:
None found.
Features:
(shadow sort emacsbug message format-spec rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils etags mail-extr dired
vc-cvs vc-rcs make-mode pcmpl-rpm tabify man sh-script smie executable
conf-mode imenu nroff-mode python rx cus-edit wid-edit cus-start
cus-load perl-mode ffap url-parse auth-source eieio gnus-util mm-util
mail-prsvr password-cache url-vars dabbrev edmacro kmacro mule-util
log-edit diff-mode nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util
rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph
nxml-enc xmltok misearch multi-isearch add-log log-view easy-mmode
pcvs-util vc vc-dispatcher vc-svn sql thingatpt help-mode pcmpl-unix
time-date server csharp-mode warnings advice help-fns advice-preload
byte-opt bytecomp byte-compile cconv cc-langs cc-mode cc-fonts easymenu
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
zoom-frm frame-cmds frame-fns cl-macs gv avoid cl cl-lib compile shell
pcomplete comint ring ansi-color tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
--
Ed Avis <eda@waniasset.com>
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18915: 24.3; Feature: Prompt to make executable on write-file
2014-10-31 18:01 bug#18915: 24.3; Feature: Prompt to make executable on write-file Ed Avis
@ 2014-10-31 18:06 ` Glenn Morris
2014-10-31 18:12 ` Ed Avis
2014-10-31 20:34 ` Stefan Monnier
2014-10-31 21:16 ` Stefan Monnier
1 sibling, 2 replies; 7+ messages in thread
From: Glenn Morris @ 2014-10-31 18:06 UTC (permalink / raw)
To: Ed Avis; +Cc: 18915
Ed Avis wrote:
> (if you edit a script and save a copy, you'll probably want to run the
> new script).
The existing
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
already handles that particular case, so personally I don't see the need
for a new, more general feature for this.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18915: 24.3; Feature: Prompt to make executable on write-file
2014-10-31 18:06 ` Glenn Morris
@ 2014-10-31 18:12 ` Ed Avis
2014-10-31 20:34 ` Stefan Monnier
1 sibling, 0 replies; 7+ messages in thread
From: Ed Avis @ 2014-10-31 18:12 UTC (permalink / raw)
To: 'Glenn Morris'; +Cc: 18915@debbugs.gnu.org
You suggested
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
That is useful, but it does make *all* newly created shebang files executable.
Which could be considered mildly dangerous; in other words, this hook cannot be on by default in a vanilla Emacs.
I suggest that Emacs usability would be improved by prompting to make a file executable,
and that since this is both safe and beginner-friendly (and doesn't get in the way of experts,
who will surely also want the execute bit on their scripts most of the time) it could be made
part of the default Emacs configuration.
It is not that important whether 'scriptness' is detected by looking for a shebang line or
by whether the file originally visited had the execute bit set. In practice either test would
give the same effect.
--
Ed Avis <eda@waniasset.com>
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18915: 24.3; Feature: Prompt to make executable on write-file
2014-10-31 18:06 ` Glenn Morris
2014-10-31 18:12 ` Ed Avis
@ 2014-10-31 20:34 ` Stefan Monnier
2014-10-31 20:54 ` Ed Avis
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-10-31 20:34 UTC (permalink / raw)
To: Glenn Morris; +Cc: 18915, Ed Avis
> (add-hook 'after-save-hook
> 'executable-make-buffer-file-executable-if-script-p)
>
> already handles that particular case, so personally I don't see the need
> for a new, more general feature for this.
Also, FWIW, I use such a hook in my .emacs and have found it
occasionally harmful, e.g. when editing the emacs/test/indent/scheme.scm
file, which then gets it `execute' bit set, even though it's not meant
to be executed.
Tho I guess it'd be OK to mark those files as executable, but I can't
get myself to do it, so I regularly end up "chmod -x"ing those files
after editing them.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18915: 24.3; Feature: Prompt to make executable on write-file
2014-10-31 20:34 ` Stefan Monnier
@ 2014-10-31 20:54 ` Ed Avis
0 siblings, 0 replies; 7+ messages in thread
From: Ed Avis @ 2014-10-31 20:54 UTC (permalink / raw)
To: Stefan Monnier, Glenn Morris; +Cc: 18915@debbugs.gnu.org
>Also, FWIW, I use such a hook in my .emacs and have found it occasionally harmful,
I agree, making the file executable silently is not a good idea. It needs a prompt.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18915: 24.3; Feature: Prompt to make executable on write-file
2014-10-31 18:01 bug#18915: 24.3; Feature: Prompt to make executable on write-file Ed Avis
2014-10-31 18:06 ` Glenn Morris
@ 2014-10-31 21:16 ` Stefan Monnier
2021-12-02 12:21 ` Lars Ingebrigtsen
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2014-10-31 21:16 UTC (permalink / raw)
To: Ed Avis; +Cc: 18915
> It would be useful if Emacs on write-file would first write the
> new file, and then (only if that involved creating the new file,
> and only if the buffer was previously visiting an executable file)
> prompt for whether to make the newly written file executable.
That could be done, even without prompting, I think.
The main downside is that I feel this covers only a very small corner case.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18915: 24.3; Feature: Prompt to make executable on write-file
2014-10-31 21:16 ` Stefan Monnier
@ 2021-12-02 12:21 ` Lars Ingebrigtsen
0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-02 12:21 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 18915, Ed Avis
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> It would be useful if Emacs on write-file would first write the
>> new file, and then (only if that involved creating the new file,
>> and only if the buffer was previously visiting an executable file)
>> prompt for whether to make the newly written file executable.
>
> That could be done, even without prompting, I think.
So I've now done this in Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-02 12:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31 18:01 bug#18915: 24.3; Feature: Prompt to make executable on write-file Ed Avis
2014-10-31 18:06 ` Glenn Morris
2014-10-31 18:12 ` Ed Avis
2014-10-31 20:34 ` Stefan Monnier
2014-10-31 20:54 ` Ed Avis
2014-10-31 21:16 ` Stefan Monnier
2021-12-02 12:21 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.