emacs-devel
[Top][All Lists]
Advanced

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

Re: File modes facilities.


From: Kevin Ryde
Subject: Re: File modes facilities.
Date: Thu, 20 Oct 2005 11:42:56 +1000
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Michael Cadilhac <address@hidden> writes:
>
>   - chmod: Change the mode of any file.

I made myself M-x chmod below, to change the current visited file.  I
usually just want to make a script executable.  I know there's an
executable-chmod or something, but I can never remember and prefer
typing 755 or 700.  The save-buffer is in case it's a new file.


(defun chmod (mode)
  "Set the mode of the current file, as per the chmod program."
  (interactive "sMode (3 or 4 octal digits): ")
  (if (string-match "[0-3]?[0-7][0-7][0-7]" mode)
      (progn
        (unless (file-exists-p (buffer-file-name))
          (save-buffer))
        (set-file-modes (buffer-file-name) (string-to-number mode 8)))
    (error "Invalid mode")))




reply via email to

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