Subject: bug#24103: 25.1.50; Add white space separator when appending string

From: Tino Calancha <[email-masked]>
Date: Fri, 29 Jul 2016 23:29:50 +0900 (JST)

On Fri, 29 Jul 2016, Eli Zaretskii wrote:

>> The command provide a nice way to do that as mentioned in the doc 
string:
>> C-u 0 w
>
> No, that produces the absolute names of files in the directory shown
> by Dired, whereas what I meant is constructing a name of a file in
> another directory by concatenating a directory killed in another kill
> command and the file name killed by 'w'.
Agreed.  It might be useful.

>> From: Tino Calancha <[email-masked]>
>> Date: Fri, 29 Jul 2016 19:27:30 +0900 (JST)
>> cc: Tino Calancha <[email-masked]>, [email-masked]

> Sorry, I don't understand: which part of the fix you suggest to skip,
> and what will be left then?
So, the patch now fix the II) in the report: it prevent to change the kill
ring when the string is empty.
The command name and the doc string suggest the usage is about copying
file names.
I would prefer if this command have effect just when point is:

1) on a line showing a subdir name
for instance:
(dired-subdir-min)

2) on a line showing a file from the dired listing
on a line displaying a file or subddir name
for instance,
(progn (goto-char (dired-subdir-min)) (dired-goto-next-file) (point))

Currently the command is enabled whatever is the point in the Dired 
buffer.  As a consequence, the command put a "" in the kill ring if
the command is called with the point in one position other than 1) 2)
for instance:
3)
(progn (goto-char (dired-subdir-min)) (forward-line 1) (point))

I would propose in order of preference:

A) Do not change the kill ring when the command is called with point
    in a position like 3) (See patch below).
B) Update the doc string alerting that the command is responsive even
    if there is no filename/subdir accesible: the kill ring will get "" in
    that cases.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From c7c1312e4acf942742e387a474d368266b48dc99 Mon Sep 17 00:00:00 2001
From: Tino Calancha <[email-masked]>
Date: Fri, 29 Jul 2016 23:06:16 +0900
Subject: [PATCH] Copy just non-empty strings to kill-ring

* lisp/dired.el (dired-copy-filename-as-kill):
Do not change the kill ring when the string is empty. (Bug#24103).
---
  lisp/dired.el | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 5d14291..7ead087 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2467,10 +2467,11 @@ dired-copy-filename-as-kill
  				    'no-dir (prefix-numeric-value arg))))
                            (dired-get-marked-files 'no-dir))
                          " "))))
-    (if (eq last-command 'kill-region)
-	(kill-append string nil)
-      (kill-new string))
-    (message "%s" string)))
+    (unless (string= string "")
+      (if (eq last-command 'kill-region)
+          (kill-append string nil)
+        (kill-new string))
+      (message "%s" string))))

  ;; Keeping Dired buffers in sync with the filesystem and with each other
-- 
2.8.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

GNU Emacs 25.1.50 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6)
  of 2016-07-28
Repository revision: 4a5b6e621c68172bb69d60fe8a76932f7c779f81