unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#21851: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name
@ 2015-11-07 15:12 Tino Calancha
  2016-02-23  5:07 ` Lars Ingebrigtsen
  2016-04-27 11:13 ` bug#21851: (no subject) Tino Calancha
  0 siblings, 2 replies; 4+ messages in thread
From: Tino Calancha @ 2015-11-07 15:12 UTC (permalink / raw)
  To: kifer, 21851; +Cc: Tino Calancha

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


Congratulations!  You may have unearthed a bug in Ediff!

Please make a concise and accurate summary of what happened
and mail it to the address above.
-----------------------------------------------------------

ediff-patch-file fails if patch-buf is a buffer name

* lisp/vc/ediff.el (ediff-patch-file)

emacs -Q:
(in *scratch* buffer)

(with-temp-file "/tmp/buff"
   (insert "foo bar"))

(with-current-buffer (generate-new-buffer "buff2")
   (insert "foo baz"))

;; call ediff-buffers on "buff" and "buff2" and save the
;; differences in a buffer "patch"

(epatch nil (get-buffer "patch")) ; ok
(epatch nil "patch") ; BAD
epatch: Wrong type argument: bufferp, "patch"


Emacs  : GNU Emacs 25.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.28)
  of 2015-11-07
Package: Ediff 2.81.5 of July 4, 2013

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

diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 3a2d1e4..e5c12cc 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -1367,7 +1367,8 @@ ediff-patch-file
     (require 'ediff-ptch)
     (setq patch-buf
 	  (ediff-get-patch-buffer
-	   (if arg (prefix-numeric-value arg)) patch-buf))
+	   (if arg (prefix-numeric-value arg)) (and (stringp patch-buf)
+                                                    (get-buffer patch-buf))))
     (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
 			   ((and (not ediff-patch-default-directory)
 				 (buffer-file-name patch-buf))

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

* bug#21851: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name
  2015-11-07 15:12 bug#21851: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name Tino Calancha
@ 2016-02-23  5:07 ` Lars Ingebrigtsen
  2016-03-10  5:08   ` Tino Calancha
  2016-04-27 11:13 ` bug#21851: (no subject) Tino Calancha
  1 sibling, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-23  5:07 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 21851, kifer

Tino Calancha <f92capac@gmail.com> writes:

> (epatch nil (get-buffer "patch")) ; ok
> (epatch nil "patch") ; BAD
> epatch: Wrong type argument: bufferp, "patch"

[...]

> -	   (if arg (prefix-numeric-value arg)) patch-buf))
> +	   (if arg (prefix-numeric-value arg)) (and (stringp patch-buf)
> +                                                    (get-buffer patch-buf))))

I don't think that's quite right -- now it'll error out if patch-buf is
a real buffer.

So I've applied the following instead:

diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index e5e16a1..be4ced9 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -1367,7 +1367,8 @@ ediff-patch-file
     (require 'ediff-ptch)
     (setq patch-buf
 	  (ediff-get-patch-buffer
-	   (if arg (prefix-numeric-value arg)) patch-buf))
+	   (if arg (prefix-numeric-value arg))
+           (get-buffer patch-buf)))
     (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
 			   ((and (not ediff-patch-default-directory)
 				 (buffer-file-name patch-buf))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#21851: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name
  2016-02-23  5:07 ` Lars Ingebrigtsen
@ 2016-03-10  5:08   ` Tino Calancha
  0 siblings, 0 replies; 4+ messages in thread
From: Tino Calancha @ 2016-03-10  5:08 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Tino Calancha, 21851, kifer


> I don't think that's quite right -- now it'll error out if patch-buf is
> a real buffer.
>
> So I've applied the following instead:
>
> diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
> index e5e16a1..be4ced9 100644
> --- a/lisp/vc/ediff.el
> +++ b/lisp/vc/ediff.el
> @@ -1367,7 +1367,8 @@ ediff-patch-file
>     (require 'ediff-ptch)
>     (setq patch-buf
> 	  (ediff-get-patch-buffer
> -	   (if arg (prefix-numeric-value arg)) patch-buf))
> +	   (if arg (prefix-numeric-value arg))
> +           (get-buffer patch-buf)))
>     (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
> 			   ((and (not ediff-patch-default-directory)
> 				 (buffer-file-name patch-buf))
>

the interactive calls neesome adjust:
M-x ediff-patch-file RET
;; signals error: 
Wrong type argument: stringp, nil

The doc. string starts with "Query for a file name ...",
it should prompt user for a file in this case, right?





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

* bug#21851: (no subject)
  2015-11-07 15:12 bug#21851: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name Tino Calancha
  2016-02-23  5:07 ` Lars Ingebrigtsen
@ 2016-04-27 11:13 ` Tino Calancha
  1 sibling, 0 replies; 4+ messages in thread
From: Tino Calancha @ 2016-04-27 11:13 UTC (permalink / raw)
  To: 21851


Hi Lars,

i think this thread should be considered a wish list; the
doc. string doesn't say that PATCH-BUF could be a buffer name:

"If optional PATCH-BUF is given, use the patch in that buffer
and don't ask the user."

So in principle there is nothing wrong if
(epatch nil "buffer-name")
signal an error.  In fact, most of the folks would call this
function interactively, so there would not be issue at all.

*) If we prefer to keep the code as it is, maybe is worth to remark
    in the doc. string the type of PATCH-BUF, someting like:

"If optional arg PATCH-BUF non-nil, then it is a buffer containing
the patch; use that patch and don't ask the user."

*) We may extend this function, so that, PATCH-BUF is a buffer
    or the name of a buffer, like in many others functions in emacs.
    Following patch do that:

diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index 71099ab..f9f2370 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -1367,7 +1367,9 @@ ediff-patch-file
      (require 'ediff-ptch)
      (setq patch-buf
           (ediff-get-patch-buffer
-          (if arg (prefix-numeric-value arg)) patch-buf))
+          (and arg (prefix-numeric-value arg))
+           (and (or (stringp patch-buf) (bufferp patch-buf))
+                (get-buffer patch-buf))))
      (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
                            ((and (not ediff-patch-default-directory)
                                  (buffer-file-name patch-buf))


"GNU Emacs 25.0.93.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
  of 2016-04-27"






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

end of thread, other threads:[~2016-04-27 11:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-07 15:12 bug#21851: ediff-patch-file fails if patch-buf is a buffer nameif patch-buf is a buffer name Tino Calancha
2016-02-23  5:07 ` Lars Ingebrigtsen
2016-03-10  5:08   ` Tino Calancha
2016-04-27 11:13 ` bug#21851: (no subject) Tino Calancha

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