* Re: How to put default-directory into kill-ring?
@ 2014-02-12 14:44 Barry OReilly
2014-02-12 15:14 ` Stefan Monnier
0 siblings, 1 reply; 17+ messages in thread
From: Barry OReilly @ 2014-02-12 14:44 UTC (permalink / raw)
To: mbork, help-gnu-emacs
> quite often I want to put some full path to some file (usually
> init.el). It would be quite convenient for M-x pwd (or maybe C-u M-x
> pwd?) to put its output into the kill ring, which is does not. So:
> is there any function to do this? (I can easily write it myself, but
> don't want to reinvent the wheel.) If not, could this be considered
> a feature request?
I usually go to buffer-menu and copy the buffer name, path, whatever.
I bind buffer-menu to 'f' in an Evil keymap because of how often I use
it. So in this setup, the typed keys for copying the absolute
directory path containing the current file would be: f$?/ then RET
then vBy .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-12 14:44 How to put default-directory into kill-ring? Barry OReilly
@ 2014-02-12 15:14 ` Stefan Monnier
2014-02-14 12:41 ` Marcin Borkowski
2014-02-14 12:59 ` Michael Heerdegen
0 siblings, 2 replies; 17+ messages in thread
From: Stefan Monnier @ 2014-02-12 15:14 UTC (permalink / raw)
To: help-gnu-emacs
>> quite often I want to put some full path to some file (usually
>> init.el). It would be quite convenient for M-x pwd (or maybe C-u M-x
>> pwd?) to put its output into the kill ring, which is does not. So:
>> is there any function to do this? (I can easily write it myself, but
>> don't want to reinvent the wheel.) If not, could this be considered
>> a feature request?
We could provide such a feature, of course. If you have a good UI for
it, please tell.
When I need such a thing, I usually use something like C-x C-f
then copy the part I want, then C-g.
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-12 15:14 ` Stefan Monnier
@ 2014-02-14 12:41 ` Marcin Borkowski
2014-02-14 13:24 ` Stefan Monnier
2014-02-14 12:59 ` Michael Heerdegen
1 sibling, 1 reply; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-14 12:41 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-02-12, o godz. 10:14:24
Stefan Monnier <monnier@iro.umontreal.ca> napisał(a):
> >> quite often I want to put some full path to some file (usually
> >> init.el). It would be quite convenient for M-x pwd (or maybe C-u
> >> M-x pwd?) to put its output into the kill ring, which is does not.
> >> So: is there any function to do this? (I can easily write it
> >> myself, but don't want to reinvent the wheel.) If not, could this
> >> be considered a feature request?
>
> We could provide such a feature, of course. If you have a good UI for
> it, please tell.
Thanks!
Well, as I wrote: M-x pwd currently does *nothing* with its prefix
argument, and only outputs the default directory in the minibuffer. So
C-u M-x pwd is basically "wasted".
Another possible use case might be to have my current directory in the
kill ring so that I can `cd' to it in an eshell buffer (assuming I
don't want to open a new one). Or even in an xterm, for that matter.
> When I need such a thing, I usually use something like C-x C-f
> then copy the part I want, then C-g.
This is not exactly the same, since then I'm stuck with the "~/" prefix
for my home directory, which may or may not be what is wanted. Also,
in case of us Ido users, this requires one more keypress (it's one more
C-f, so not *that* inconvenient, but still).
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 12:41 ` Marcin Borkowski
@ 2014-02-14 13:24 ` Stefan Monnier
2014-02-14 13:40 ` Nicolas Richard
2014-02-14 18:42 ` Marcin Borkowski
0 siblings, 2 replies; 17+ messages in thread
From: Stefan Monnier @ 2014-02-14 13:24 UTC (permalink / raw)
To: help-gnu-emacs
> Well, as I wrote: M-x pwd currently does *nothing* with its prefix
> argument, and only outputs the default directory in the minibuffer.
> So C-u M-x pwd is basically "wasted".
I guess that would be OK. Please M-x report-emacs-bug requesting this
as a new feature, to see what other developers think about it (and so
it's not forgotten until the trunk is unfrozen).
I think M-: would also benefit from changing its "C-u means to insert at
point" to "C-u means to stash in the kill-ring". Tho, if we could find
a generic way to "get the message from this command and stash it in the
kill-ring" it might be even better.
> Also, in case of us Ido users, this requires one more keypress (it's
> one more C-f, so not *that* inconvenient, but still).
Yup, one of the reasons why Ido will never be the default completion UI.
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 13:24 ` Stefan Monnier
@ 2014-02-14 13:40 ` Nicolas Richard
2014-02-14 16:32 ` Stefan Monnier
2014-02-14 18:41 ` Marcin Borkowski
2014-02-14 18:42 ` Marcin Borkowski
1 sibling, 2 replies; 17+ messages in thread
From: Nicolas Richard @ 2014-02-14 13:40 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Well, as I wrote: M-x pwd currently does *nothing* with its prefix
>> argument, and only outputs the default directory in the minibuffer.
>> So C-u M-x pwd is basically "wasted".
>
> I guess that would be OK. Please M-x report-emacs-bug requesting this
> as a new feature, to see what other developers think about it (and so
> it's not forgotten until the trunk is unfrozen).
>
> I think M-: would also benefit from changing its "C-u means to insert at
> point" to "C-u means to stash in the kill-ring". Tho, if we could find
> a generic way to "get the message from this command and stash it in the
> kill-ring" it might be even better.
As a related question, I wish I had something for getting what's in the
echo area. I currently uses the following heuristic:
(defun yf/save-current-or-last-echo-area ()
"Save current message in echo area as kill"
(interactive)
(let ((candidates
(list
(with-current-buffer " *Echo Area 1*"
(buffer-string))
(with-current-buffer " *Echo Area 0*"
(buffer-string))
(with-current-buffer "*Messages*"
(save-excursion
(goto-char
(point-max))
(skip-chars-backward "\n")
(buffer-substring-no-properties
(point)
(progn
(skip-chars-backward "^\n")
(point))))))))
(kill-new (car (remove "" candidates)))))
(bind-key "<f5>" 'yf/save-current-or-last-echo-area)
I have no idea why it's sometimes Echo Area 1 and sometimes 0, nor if I
might miss an Echo Area 2.
--
Nico.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 13:40 ` Nicolas Richard
@ 2014-02-14 16:32 ` Stefan Monnier
2014-02-14 18:41 ` Marcin Borkowski
1 sibling, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2014-02-14 16:32 UTC (permalink / raw)
To: Nicolas Richard; +Cc: help-gnu-emacs
> As a related question, I wish I had something for getting what's in the
> echo area.
Right, that's one solution.
> I have no idea why it's sometimes Echo Area 1 and sometimes 0,
IIRC Emacs alternates between the two for a reason that escapes me just now.
> nor if I might miss an Echo Area 2.
No, there are only 2 (contrary to the *Minibuffer-N*).
Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 13:40 ` Nicolas Richard
2014-02-14 16:32 ` Stefan Monnier
@ 2014-02-14 18:41 ` Marcin Borkowski
2014-02-14 21:31 ` Nicolas Richard
1 sibling, 1 reply; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-14 18:41 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-02-14, o godz. 14:40:03
Nicolas Richard <theonewiththeevillook@yahoo.fr> napisał(a):
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> >> Well, as I wrote: M-x pwd currently does *nothing* with its prefix
> >> argument, and only outputs the default directory in the minibuffer.
> >> So C-u M-x pwd is basically "wasted".
> >
> > I guess that would be OK. Please M-x report-emacs-bug requesting
> > this as a new feature, to see what other developers think about it
> > (and so it's not forgotten until the trunk is unfrozen).
> >
> > I think M-: would also benefit from changing its "C-u means to
> > insert at point" to "C-u means to stash in the kill-ring". Tho, if
> > we could find a generic way to "get the message from this command
> > and stash it in the kill-ring" it might be even better.
>
> As a related question, I wish I had something for getting what's in
> the echo area. I currently uses the following heuristic:
> (defun yf/save-current-or-last-echo-area ()
> "Save current message in echo area as kill"
> (interactive)
> (let ((candidates
> (list
> (with-current-buffer " *Echo Area 1*"
> (buffer-string))
> (with-current-buffer " *Echo Area 0*"
> (buffer-string))
> (with-current-buffer "*Messages*"
> (save-excursion
> (goto-char
> (point-max))
> (skip-chars-backward "\n")
> (buffer-substring-no-properties
> (point)
> (progn
> (skip-chars-backward "^\n")
> (point))))))))
> (kill-new (car (remove "" candidates)))))
> (bind-key "<f5>" 'yf/save-current-or-last-echo-area)
>
> I have no idea why it's sometimes Echo Area 1 and sometimes 0, nor if
> I might miss an Echo Area 2.
I like this approach a lot! BTW, is checking " *Echo Area [01]*" even
necessary? I mean, its contents should be in "*Messages*" anyway,
right?
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 18:41 ` Marcin Borkowski
@ 2014-02-14 21:31 ` Nicolas Richard
0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Richard @ 2014-02-14 21:31 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: help-gnu-emacs
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> Nicolas Richard <theonewiththeevillook@yahoo.fr> napisał(a):
>> As a related question, I wish I had something for getting what's in
>> the echo area. I currently uses the following heuristic:
>> [...]
> I like this approach a lot! BTW, is checking " *Echo Area [01]*" even
> necessary? I mean, its contents should be in "*Messages*" anyway,
> right?
Some commands bind message-log-max to nil for various reasons, so it's
not always the same content (or might slightly differ, ISTR I have seen
that on occasions).
--
Nico.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 13:24 ` Stefan Monnier
2014-02-14 13:40 ` Nicolas Richard
@ 2014-02-14 18:42 ` Marcin Borkowski
1 sibling, 0 replies; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-14 18:42 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-02-14, o godz. 08:24:36
Stefan Monnier <monnier@iro.umontreal.ca> napisał(a):
> > Well, as I wrote: M-x pwd currently does *nothing* with its prefix
> > argument, and only outputs the default directory in the minibuffer.
> > So C-u M-x pwd is basically "wasted".
>
> I guess that would be OK. Please M-x report-emacs-bug requesting this
> as a new feature, to see what other developers think about it (and so
> it's not forgotten until the trunk is unfrozen).
Thanks, I'll do it!
> I think M-: would also benefit from changing its "C-u means to insert
> at point" to "C-u means to stash in the kill-ring". Tho, if we could
> find a generic way to "get the message from this command and stash it
> in the kill-ring" it might be even better.
Certainly.
> > Also, in case of us Ido users, this requires one more keypress (it's
> > one more C-f, so not *that* inconvenient, but still).
>
> Yup, one of the reasons why Ido will never be the default completion
> UI.
Obvious. Ido can be *very* annoying, having it as a default would be
an extremely bad idea.
> Stefan
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-12 15:14 ` Stefan Monnier
2014-02-14 12:41 ` Marcin Borkowski
@ 2014-02-14 12:59 ` Michael Heerdegen
2014-02-14 18:40 ` Marcin Borkowski
1 sibling, 1 reply; 17+ messages in thread
From: Michael Heerdegen @ 2014-02-14 12:59 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> We could provide such a feature, of course. If you have a good UI for
> it, please tell.
FWIW, my two cents: There are surely different use cases. Another
scenario, which is probably different from Marcin's: Getting paths to
other window system applications. That can even be another Emacs
instance where you want to try and load a file you edited in the first
instance. But most often, I need the path of a file or directory to be
pasted into another application, e.g. for opening or save-to dialogues.
My approach for that problem is the following:
Double clicking on the buffer name in the mode-line pushes its path into
the kill-ring and into the primary selection. Double clicking on a file
in dired does the same. Using the mouse for this is quite convenient,
because you can continue switching to the other application and paste
the path there without switching input device.
Michael.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-14 12:59 ` Michael Heerdegen
@ 2014-02-14 18:40 ` Marcin Borkowski
0 siblings, 0 replies; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-14 18:40 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-02-14, o godz. 13:59:06
Michael Heerdegen <michael_heerdegen@web.de> napisał(a):
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> > We could provide such a feature, of course. If you have a good UI
> > for it, please tell.
>
> FWIW, my two cents: There are surely different use cases. Another
> scenario, which is probably different from Marcin's: Getting paths to
> other window system applications. That can even be another Emacs
> instance where you want to try and load a file you edited in the first
> instance. But most often, I need the path of a file or directory to
> be pasted into another application, e.g. for opening or save-to
> dialogues.
>
> My approach for that problem is the following:
>
> Double clicking on the buffer name in the mode-line pushes its path
> into the kill-ring and into the primary selection. Double clicking
> on a file in dired does the same. Using the mouse for this is quite
> convenient, because you can continue switching to the other
> application and paste the path there without switching input device.
Interesting. I hate using the mouse (even for switching applications),
so definitely not for me.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* How to put default-directory into kill-ring?
@ 2014-02-04 11:07 Marcin Borkowski
2014-02-04 11:46 ` Thorsten Jolitz
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-04 11:07 UTC (permalink / raw)
To: GNU Emacs users list
Hi list,
quite often I want to put some full path to some file (usually
init.el). It would be quite convenient for M-x pwd (or maybe C-u M-x
pwd?) to put its output into the kill ring, which is does not. So: is
there any function to do this? (I can easily write it myself, but
don't want to reinvent the wheel.) If not, could this be considered a
feature request?
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-04 11:07 Marcin Borkowski
@ 2014-02-04 11:46 ` Thorsten Jolitz
2014-02-05 17:03 ` Marcin Borkowski
2014-02-04 14:01 ` Drew Adams
2014-02-04 17:34 ` Leo Liu
2 siblings, 1 reply; 17+ messages in thread
From: Thorsten Jolitz @ 2014-02-04 11:46 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
Hi Marcin,
> quite often I want to put some full path to some file (usually
> init.el). It would be quite convenient for M-x pwd (or maybe C-u M-x
> pwd?) to put its output into the kill ring, which is does not. So: is
> there any function to do this? (I can easily write it myself, but
> don't want to reinvent the wheel.) If not, could this be considered a
> feature request?
I use this in dired (typing '0 w' with point on a file/dir):
,-----------------------------------------------------------------------------
| w runs the command dired-copy-filename-as-kill, which is an
| interactive compiled Lisp function in `dired.el'.
|
| It is bound to w, <menu-bar> <operate> <kill-ring>.
|
| (dired-copy-filename-as-kill &optional ARG)
|
| Copy names of marked (or next ARG) files into the kill ring.
| The names are separated by a space.
| With a zero prefix arg, use the absolute file name of each marked file.
| With C-u, use the file name relative to the dired buffer's
| `default-directory'. (This still may contain slashes if in a subdirectory.)
`-----------------------------------------------------------------------------
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-04 11:46 ` Thorsten Jolitz
@ 2014-02-05 17:03 ` Marcin Borkowski
0 siblings, 0 replies; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-05 17:03 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-02-04, o godz. 12:46:25
Thorsten Jolitz <tjolitz@gmail.com> napisał(a):
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
> Hi Marcin,
>
> > quite often I want to put some full path to some file (usually
> > init.el). It would be quite convenient for M-x pwd (or maybe C-u
> > M-x pwd?) to put its output into the kill ring, which is does not.
> > So: is there any function to do this? (I can easily write it
> > myself, but don't want to reinvent the wheel.) If not, could this
> > be considered a feature request?
>
> I use this in dired (typing '0 w' with point on a file/dir):
Thanks, I didn't know that!
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: How to put default-directory into kill-ring?
2014-02-04 11:07 Marcin Borkowski
2014-02-04 11:46 ` Thorsten Jolitz
@ 2014-02-04 14:01 ` Drew Adams
2014-02-05 17:03 ` Marcin Borkowski
2014-02-04 17:34 ` Leo Liu
2 siblings, 1 reply; 17+ messages in thread
From: Drew Adams @ 2014-02-04 14:01 UTC (permalink / raw)
To: Marcin Borkowski, GNU Emacs users list
> is there any function to do this?
M-x cd RET C-x DEL C-g
`cd' changes directory, and the default is `default-directory'.
`C-x DEL' is `backward-kill-sentence', which kills the dir
in the minibuffer. You can alternatively use `C-a C-k' to do
this. (DEL is Backspace.)
If you have `insert-default-directory' = nil then do `M-n'
after `M-x cd RET', to get the default dir in the minibuffer.
And yes, if you do this often, you could simply define a
command and key for it.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-04 14:01 ` Drew Adams
@ 2014-02-05 17:03 ` Marcin Borkowski
0 siblings, 0 replies; 17+ messages in thread
From: Marcin Borkowski @ 2014-02-05 17:03 UTC (permalink / raw)
To: help-gnu-emacs
Dnia 2014-02-04, o godz. 06:01:14
Drew Adams <drew.adams@oracle.com> napisał(a):
> > is there any function to do this?
>
> M-x cd RET C-x DEL C-g
>
> `cd' changes directory, and the default is `default-directory'.
> `C-x DEL' is `backward-kill-sentence', which kills the dir
> in the minibuffer. You can alternatively use `C-a C-k' to do
> this. (DEL is Backspace.)
>
> If you have `insert-default-directory' = nil then do `M-n'
> after `M-x cd RET', to get the default dir in the minibuffer.
This is a bit lengthy, but thanks nonetheless.
> And yes, if you do this often, you could simply define a
> command and key for it.
Of course.
Thanks!
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: How to put default-directory into kill-ring?
2014-02-04 11:07 Marcin Borkowski
2014-02-04 11:46 ` Thorsten Jolitz
2014-02-04 14:01 ` Drew Adams
@ 2014-02-04 17:34 ` Leo Liu
2 siblings, 0 replies; 17+ messages in thread
From: Leo Liu @ 2014-02-04 17:34 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: GNU Emacs users list
On 2014-02-04 19:07 +0800, Marcin Borkowski wrote:
> quite often I want to put some full path to some file (usually
> init.el). It would be quite convenient for M-x pwd (or maybe C-u M-x
> pwd?) to put its output into the kill ring, which is does not. So: is
> there any function to do this? (I can easily write it myself, but
> don't want to reinvent the wheel.) If not, could this be considered a
> feature request?
A small package for many such tasks: https://github.com/leoliu/easy-kill
M-w b copies buffer-file-name or default-directory with the following
keys modifies the kill:
-: remove the basename
0: remove the directory name
+: full path
Leo
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2014-02-14 21:31 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-12 14:44 How to put default-directory into kill-ring? Barry OReilly
2014-02-12 15:14 ` Stefan Monnier
2014-02-14 12:41 ` Marcin Borkowski
2014-02-14 13:24 ` Stefan Monnier
2014-02-14 13:40 ` Nicolas Richard
2014-02-14 16:32 ` Stefan Monnier
2014-02-14 18:41 ` Marcin Borkowski
2014-02-14 21:31 ` Nicolas Richard
2014-02-14 18:42 ` Marcin Borkowski
2014-02-14 12:59 ` Michael Heerdegen
2014-02-14 18:40 ` Marcin Borkowski
-- strict thread matches above, loose matches on Subject: below --
2014-02-04 11:07 Marcin Borkowski
2014-02-04 11:46 ` Thorsten Jolitz
2014-02-05 17:03 ` Marcin Borkowski
2014-02-04 14:01 ` Drew Adams
2014-02-05 17:03 ` Marcin Borkowski
2014-02-04 17:34 ` Leo Liu
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).