From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Copley Newsgroups: gmane.emacs.help Subject: Re: How to change and save a read-only file? Date: Mon, 1 Jul 2013 23:35:45 +0100 Message-ID: References: <87ip0xnjtx.fsf@VLAN-3434.student.uu.se> <87d2r5nixr.fsf@VLAN-3434.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1372718161 22655 80.91.229.3 (1 Jul 2013 22:36:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Jul 2013 22:36:01 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 02 00:36:00 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 1UtmhT-0000D8-SV for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Jul 2013 00:35:59 +0200 Original-Received: from localhost ([::1]:35790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtmhT-0005u6-6b for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Jul 2013 18:35:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtmhI-0005u1-S5 for help-gnu-emacs@gnu.org; Mon, 01 Jul 2013 18:35:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtmhH-0000oj-NS for help-gnu-emacs@gnu.org; Mon, 01 Jul 2013 18:35:48 -0400 Original-Received: from mail-ea0-x22a.google.com ([2a00:1450:4013:c01::22a]:54902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtmhH-0000oY-3x for help-gnu-emacs@gnu.org; Mon, 01 Jul 2013 18:35:47 -0400 Original-Received: by mail-ea0-f170.google.com with SMTP id h10so2377369eaj.29 for ; Mon, 01 Jul 2013 15:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=4rL2KAKUlAjXjeuw6d38TuOo17REwKV0L4jpLRezYZo=; b=RcsEdgcZ6yNE1JjBLS9KDWl7alVkwCURQQxJ6l/OlaAChFmXoYYCWZxtbwcCacZmG3 OcqObXYXCyy68g00kTuk4N0g+Wx3trqOGRgr8H/aKVXwFfHvrNAgvjiIgIEZZGX0E9aw E1HZ8YR+Njf4K28kWscbqKrS7QBxT2bH7kaa6zvY2GkvAJBldVy9sn+MxCYQxfPpJVti NGH27fk3XqBXpZ3QMKFyuoCNXtIOsKsp6flpbBpcqd5k3EB3FrM4lYFrzv4iFTUp1Ww6 1rwgpQRmDbVJtFOtPXpBj+k/JPqPJONiPePzC4kPUIZ5AfBZiMYZaz7Z2MKPU9hqnV42 s0eg== X-Received: by 10.15.110.197 with SMTP id ch45mr22882228eeb.149.1372718145717; Mon, 01 Jul 2013 15:35:45 -0700 (PDT) Original-Received: by 10.14.178.133 with HTTP; Mon, 1 Jul 2013 15:35:45 -0700 (PDT) In-Reply-To: <87d2r5nixr.fsf@VLAN-3434.student.uu.se> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22a 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:91894 Archived-At: On 29 June 2013 14:30, Emanuel Berg wrote: > Emanuel Berg writes: > >> (defun su-edit () >> "Edit the current buffer file as superuser - >> in a new buffer, that should look the same." >> (interactive) >> (let ((start-point-pos (point))) >> (recenter-top-bottom 0) >> (let ((top-window-pos (point)) >> (buffer (buffer-file-name)) ) >> (kill-buffer) >> (find-file (format "/sudo::%s" buffer)) >> (goto-char top-window-pos) >> (recenter-top-bottom 0) >> (goto-char start-point-pos) ))) > > Aha, now I see, `recenter-top-bottom' doesn't change the point! > Silly. Still, even though with this realization I could fix it, I > leave it open to you foxes as you more than once have provided me > with standard solutions (for which I am grateful, because they > work better - and not without pride I add that last word :) ) Not sure about "standard solution" (or "fox") but I would do it like this: (let ((window-start (window-start)) (point (point))) (find-alternate-file (format "%s~" (buffer-file-name))) (goto-char point) (set-window-start nil window-start)))