From: Richard Copley <rcopley@gmail.com>
To: Emanuel Berg <embe8573@student.uu.se>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: How to change and save a read-only file?
Date: Mon, 1 Jul 2013 23:35:45 +0100 [thread overview]
Message-ID: <CAPM58ojrE=6rypR7vvC9OZS0H3pqyF-aS-2zqSoVTPnnpxN-vA@mail.gmail.com> (raw)
In-Reply-To: <87d2r5nixr.fsf@VLAN-3434.student.uu.se>
On 29 June 2013 14:30, Emanuel Berg <embe8573@student.uu.se> wrote:
> Emanuel Berg <embe8573@student.uu.se> 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)))
next prev parent reply other threads:[~2013-07-01 22:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2780.1372497288.22516.help-gnu-emacs@gnu.org>
2013-06-29 13:10 ` How to change and save a read-only file? Emanuel Berg
2013-06-29 13:30 ` Emanuel Berg
2013-07-01 22:35 ` Richard Copley [this message]
[not found] ` <mailman.14.1372718151.12400.help-gnu-emacs@gnu.org>
2013-07-01 23:42 ` Emanuel Berg
2013-07-19 12:36 ` Emanuel Berg
2013-11-20 3:27 Emanuel Berg
2013-11-20 14:22 ` Kevin Rodgers
[not found] ` <mailman.6640.1384957268.10748.help-gnu-emacs@gnu.org>
2013-11-20 16:24 ` Emanuel Berg
-- strict thread matches above, loose matches on Subject: below --
2013-06-29 9:14 Marius Hofert
2013-06-29 9:20 ` Peter Dyballa
2013-06-29 11:04 ` Thorsten Jolitz
2013-06-29 11:16 ` Jude DaShiell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPM58ojrE=6rypR7vvC9OZS0H3pqyF-aS-2zqSoVTPnnpxN-vA@mail.gmail.com' \
--to=rcopley@gmail.com \
--cc=embe8573@student.uu.se \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.