unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A patch for `pwd' - copying the current directory to the kill ring
@ 2018-01-25 13:13 Marcin Borkowski
  2018-01-25 13:44 ` Kaushal Modi
  2018-01-25 15:47 ` Yuri Khan
  0 siblings, 2 replies; 20+ messages in thread
From: Marcin Borkowski @ 2018-01-25 13:13 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 607 bytes --]

Hi all,

from time to time I have a need to insert the current directory name
somewhere.  Some time ago, I submitted a bug report suggesting that C-u
M-x pwd could insert the current dir at point.  Someone made that patch
a few years ago, and that is great.  However, it is not enough:
sometimes I want to be able to yank this dir to some other application
(usually the terminal - I want to cd to that dir).  I made a simple
patch that makes `pwd' copy the current dir to the kill ring (and - by
default - to the system clipboard) if prefixed with C-u C-u.  I attach
the patch.  WDYT?

-- 
Marcin Borkowski

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-pwd-copy-current-dir-to-kill-ring-when-run-with.patch --]
[-- Type: text/x-patch, Size: 1289 bytes --]

From bffb831838f16182fe4e26629c0c6b85ffe98419 Mon Sep 17 00:00:00 2001
From: Marcin Borkowski <mbork@mbork.pl>
Date: Thu, 25 Jan 2018 14:06:41 +0100
Subject: [PATCH] Make pwd copy current dir to kill ring when run with C-u C-u

---
 lisp/files.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 7194b56fef..0ebc7b5b9d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -714,14 +714,16 @@ read-directory-name
 		  'file-directory-p))
 
 \f
-(defun pwd (&optional insert)
-  "Show the current default directory.
-With prefix argument INSERT, insert the current default directory
-at point instead."
+(defun pwd (&optional arg)
+  "Show the current default directory. With \\[universal-argument], insert
+the current default directory at point instead.  With \\[universal-argument] \\[universal-argument],
+show the current default directory and put it in the kill ring."
   (interactive "P")
-  (if insert
+  (if (equal arg '(4))
       (insert default-directory)
-    (message "Directory %s" default-directory)))
+    (message "Directory %s" default-directory)
+    (when (equal arg '(16))
+      (kill-new default-directory))))
 
 (defvar cd-path nil
   "Value of the CDPATH environment variable, as a list.
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-02-06 21:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-25 13:13 A patch for `pwd' - copying the current directory to the kill ring Marcin Borkowski
2018-01-25 13:44 ` Kaushal Modi
2018-01-25 14:36   ` Stefan Monnier
2018-01-25 20:13     ` Stefan Monnier
2018-01-25 23:05       ` Richard Copley
2018-01-25 23:23         ` Stefan Monnier
2018-02-01 21:11           ` Marcin Borkowski
2018-02-01 22:03             ` Alexis
2018-02-02  1:59             ` Stefan Monnier
2018-02-02  8:51               ` Eli Zaretskii
2018-02-02 17:29                 ` Stefan Monnier
2018-02-03  0:02                   ` Richard Copley
2018-02-02 23:59                 ` Richard Copley
2018-02-06 21:03               ` Marcin Borkowski
2018-01-26  7:55       ` Eli Zaretskii
2018-01-26 14:40         ` Stefan Monnier
2018-01-26 15:40           ` Eli Zaretskii
2018-02-01 21:09     ` Marcin Borkowski
2018-02-01 21:08   ` Marcin Borkowski
2018-01-25 15:47 ` Yuri Khan

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).