From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: How to change and save a read-only file? Date: Wed, 20 Nov 2013 04:27:34 +0100 Organization: Aioe.org NNTP Server Message-ID: <87wqk3da68.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1384918215 14776 80.91.229.3 (20 Nov 2013 03:30:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 20 Nov 2013 03:30:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 20 04:30:21 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ViyUe-0000wP-6w for geh-help-gnu-emacs@m.gmane.org; Wed, 20 Nov 2013 04:30:20 +0100 Original-Received: from localhost ([::1]:52676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViyUd-0003ba-Ns for geh-help-gnu-emacs@m.gmane.org; Tue, 19 Nov 2013 22:30:19 -0500 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: VVbyYd/iFZoeWNmD9i++cQ.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:BjXmzM9RnlsJtBGnOrfUwcQQ4UE= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:202270 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94539 Archived-At: It seems the thread that the subject refers to is inaccessible by Gnus, so perhaps the OP won't read this anyway, but I like to say it nonetheless, because this bug almost drove me insane. The below function cannot be used on symbolic links, because with (buffer-file-name), you'll get the name (and path) of the *link*... When used to edit and save such a link that points to a file not in $HOME, the result is that the link is *replaced* by the file, and the file (at its original place), disappears (?). The code, with the bug: (defun su-edit () "Edit the current buffer file as superuser." (interactive) (let ((window-start (window-start)) (point (point)) (mark (if mark-active (region-beginning) nil)) ) (find-alternate-file (format "/sudo::%s" (buffer-file-name))) (if mark (set-mark mark)) (goto-char point) (set-window-start nil window-start) ; nil - the selected window )) The solution, I hope, is: (file-truename (buffer-file-name)) -- Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu underground experts united: http://user.it.uu.se/~embe8573