From: Mark Slagell Date: 2002-04-19T11:46:18+09:00 Subject: Re: Emacs/Ruby Heath Holcomb wrote: > Josh Huber wrote: > >> Christian Szegedy writes: >> >> >>> Does someone know how to achieve that each >>> newly constructed Ruby files have >>> executable permission. >> > [snip] > >> >> Try this in your .emacs (or .xemacs/init.el, whichever you use): >> >> (require 'after-save-commands) >> (add-to-list 'After-save-alist >> '(("\.rb$" nil nil "chmod +x $f"))) >> >> seems to work for me... >> > > This doesn't work for me under FSF Emacs 20.7. I don't have > after-save-commands. Has anyone gotten this to work with FSF Emacs or > is it XEmacs specific? > Another approach is to make anything starting with a shebang line executable on save. The below is adapted from something posted a little over a year ago to gnu.emacs.sources by one Steve Kemp, and seems effective at least on emacs 20.7.2 but I haven't experimented with it much yet. -- Mark ;; put me in your ~/.emacs file (add-hook 'after-save-hook '(lambda () (progn (and (save-excursion (save-restriction (widen) (goto-char (point-min)) (save-match-data (looking-at "^#!")))) (shell-command (concat "chmod u+x " buffer-file-name)) (message (concat "Saved as script: " buffer-file-name)) ))))