* rename file in dired based on current [T2C round 3]
@ 2020-10-28 3:53 Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 4:23 ` Drew Adams
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-28 3:53 UTC (permalink / raw)
To: help-gnu-emacs
T2C - The Emacs Challenge Competition - round 3
How do you rename a file in dired, and get the previous/current as
a suggestion?
Let's say it is called salma-hayek.png and you want to rename it
salma-hayek-bandidas-2006.png, it is useful to get the first part
spelled out, right?
(defun dired-do-rename-suggest ()
(interactive)
(let*((file (dired-get-filename))
(old-name (dired-get-filename 'no-dir))
(new-name (read-from-minibuffer "rename to: " old-name)) )
(dired-rename-file file new-name nil) ; (NOT) OK-IF-ALREADY-EXISTS
(revert-buffer) ))
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: rename file in dired based on current [T2C round 3]
2020-10-28 3:53 rename file in dired based on current [T2C round 3] Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-10-28 4:23 ` Drew Adams
2020-10-28 4:46 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 4:32 ` Stefan Kangas
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Drew Adams @ 2020-10-28 4:23 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
> How do you rename a file in dired, and get the previous/current as
> a suggestion?
>
> Let's say it is called salma-hayek.png and you want to rename it
> salma-hayek-bandidas-2006.png, it is useful to get the first part
> spelled out, right?
>
> (defun dired-do-rename-suggest ()
> (interactive)
> (let*((file (dired-get-filename))
> (old-name (dired-get-filename 'no-dir))
> (new-name (read-from-minibuffer "rename to: " old-name)) )
> (dired-rename-file file new-name nil) ; (NOT) OK-IF-ALREADY-EXISTS
> (revert-buffer) ))
In Dired?
`R M-n'
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rename file in dired based on current [T2C round 3]
2020-10-28 4:23 ` Drew Adams
@ 2020-10-28 4:46 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-28 4:46 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
>> How do you rename a file in dired, and get the previous/current as
>> a suggestion?
>>
>> Let's say it is called salma-hayek.png and you want to rename it
>> salma-hayek-bandidas-2006.png, it is useful to get the first part
>> spelled out, right?
>>
>> (defun dired-do-rename-suggest ()
>> (interactive)
>> (let*((file (dired-get-filename))
>> (old-name (dired-get-filename 'no-dir))
>> (new-name (read-from-minibuffer "rename to: " old-name)) )
>> (dired-rename-file file new-name nil) ; (NOT) OK-IF-ALREADY-EXISTS
>> (revert-buffer) ))
>
> In Dired?
>
> `R M-n'
You are right! Thanks, I'll remove that piece of Elisp :)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rename file in dired based on current [T2C round 3]
2020-10-28 3:53 rename file in dired based on current [T2C round 3] Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 4:23 ` Drew Adams
@ 2020-10-28 4:32 ` Stefan Kangas
2020-10-28 4:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 5:34 ` Yuri Khan
2020-10-29 9:22 ` Michael Albinus
3 siblings, 1 reply; 10+ messages in thread
From: Stefan Kangas @ 2020-10-28 4:32 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> How do you rename a file in dired, and get the previous/current as
> a suggestion?
May I suggest `R M-n'?
(M-n is generally used in the minibuffer to get a default value.)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rename file in dired based on current [T2C round 3]
2020-10-28 4:32 ` Stefan Kangas
@ 2020-10-28 4:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-28 4:53 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Kangas wrote:
>> How do you rename a file in dired, and get the previous/current as
>> a suggestion?
>
> May I suggest `R M-n'?
>
> (M-n is generally used in the minibuffer to get a default value.)
Standings:
1. Daniel Martín (1)
2. Drew Adams (1)
3. Stefan Kangas (1)
4. Emanuel Berg (-4)
Rule: same score? the one who got it first is ranked first!
Don't take off your shoes just yet. This might well be a twelve
rounder and Manny "Bergman" Berg is known to be a slow starter.
Round 3 concluded.
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rename file in dired based on current [T2C round 3]
2020-10-28 3:53 rename file in dired based on current [T2C round 3] Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 4:23 ` Drew Adams
2020-10-28 4:32 ` Stefan Kangas
@ 2020-10-28 5:34 ` Yuri Khan
2020-10-28 5:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-29 9:22 ` Michael Albinus
3 siblings, 1 reply; 10+ messages in thread
From: Yuri Khan @ 2020-10-28 5:34 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Wed, 28 Oct 2020 at 10:53, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> How do you rename a file in dired, and get the previous/current as
> a suggestion?
In addition to the R M-n solution presented by other contestants, I’d
like to point out ‘dired-toggle-read-only’, bound by default to C-x
C-q, which lets you rename files by editing their names directly in
the dired buffer, then pressing C-c C-c to commit.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rename file in dired based on current [T2C round 3]
2020-10-28 5:34 ` Yuri Khan
@ 2020-10-28 5:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-28 5:51 UTC (permalink / raw)
To: help-gnu-emacs
Yuri Khan wrote:
>> How do you rename a file in dired, and get the previous/current as
>> a suggestion?
>
> In addition to the R M-n solution presented by other contestants,
> I’d like to point out ‘dired-toggle-read-only’, bound by default to
> C-x C-q, which lets you rename files by editing their names directly
> in the dired buffer, then pressing C-c C-c to commit.
???
You are right!
A bizarre/psychedelic feeling, almost! (Might help I have Emacs on
a project in a Linux VT. Try it! You experience everything so
much stronger...)
This solution amounts to virtually the same - because you already
have point at the file, so there is no tour. Only the C-x C-q isn't
familiar to me - maybe should change that... (ha. what does
that mean?)
+1
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: rename file in dired based on current [T2C round 3]
2020-10-28 3:53 rename file in dired based on current [T2C round 3] Emanuel Berg via Users list for the GNU Emacs text editor
` (2 preceding siblings ...)
2020-10-28 5:34 ` Yuri Khan
@ 2020-10-29 9:22 ` Michael Albinus
2020-10-30 16:12 ` H. Dieter Wilhelm
3 siblings, 1 reply; 10+ messages in thread
From: Michael Albinus @ 2020-10-29 9:22 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> T2C - The Emacs Challenge Competition - round 3
>
> How do you rename a file in dired, and get the previous/current as
> a suggestion?
I might be a little bit late, but here's another shot:
'w R C-y'
Best regards, Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-10-30 16:29 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-28 3:53 rename file in dired based on current [T2C round 3] Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 4:23 ` Drew Adams
2020-10-28 4:46 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 4:32 ` Stefan Kangas
2020-10-28 4:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-28 5:34 ` Yuri Khan
2020-10-28 5:51 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-29 9:22 ` Michael Albinus
2020-10-30 16:12 ` H. Dieter Wilhelm
2020-10-30 16:29 ` Michael Albinus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).