unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
@ 2010-09-08 12:51 Julien Danjou
  2010-09-10 21:25 ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Julien Danjou @ 2010-09-08 12:51 UTC (permalink / raw)
  To: emacs-devel; +Cc: Julien Danjou

Currently, `buff' is marked as optional, but if it is set to nil, the
function does nothing.

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 lisp/url/ChangeLog    |    5 +++++
 lisp/url/url-cache.el |   13 +++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index e3f76e7..2a69b48 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-08  Julien Danjou  <julien@danjou.info>
+
+	* url-cache (url-store-in-cache): Make `buff' argument really
+	optional by using (current-buffer) if `buff' is nil.
+
 2010-07-27  Michael Albinus  <michael.albinus@gmx.de>
 
 	* url-http (url-http-parse-headers): Disable file name handlers at
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 71841c9..ebd9f61 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -62,14 +62,11 @@ FILE can be created or overwritten."
 ;;;###autoload
 (defun url-store-in-cache (&optional buff)
   "Store buffer BUFF in the cache."
-  (if (not (and buff (get-buffer buff)))
-      nil
-    (save-current-buffer
-      (and buff (set-buffer buff))
-      (let* ((fname (url-cache-create-filename (url-view-url t))))
-	(if (url-cache-prepare fname)
-	    (let ((coding-system-for-write 'binary))
-	      (write-region (point-min) (point-max) fname nil 5)))))))
+    (with-current-buffer (get-buffer (or buff (current-buffer)))
+      (let ((fname (url-cache-create-filename (url-view-url t))))
+        (if (url-cache-prepare fname)
+            (let ((coding-system-for-write 'binary))
+              (write-region (point-min) (point-max) fname nil 5))))))
 
 ;;;###autoload
 (defun url-is-cached (url)
-- 
1.7.1




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

* Re: [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
  2010-09-08 12:51 [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional Julien Danjou
@ 2010-09-10 21:25 ` Glenn Morris
  2010-09-10 21:40   ` Glenn Morris
  0 siblings, 1 reply; 6+ messages in thread
From: Glenn Morris @ 2010-09-10 21:25 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

Julien Danjou wrote:

>  (defun url-store-in-cache (&optional buff)
>    "Store buffer BUFF in the cache."
> -  (if (not (and buff (get-buffer buff)))
> -      nil
> -    (save-current-buffer
> -      (and buff (set-buffer buff))
> -      (let* ((fname (url-cache-create-filename (url-view-url t))))
> -	(if (url-cache-prepare fname)
> -	    (let ((coding-system-for-write 'binary))
> -	      (write-region (point-min) (point-max) fname nil 5)))))))
> +    (with-current-buffer (get-buffer (or buff (current-buffer)))
> +      (let ((fname (url-cache-create-filename (url-view-url t))))
> +        (if (url-cache-prepare fname)
> +            (let ((coding-system-for-write 'binary))
> +              (write-region (point-min) (point-max) fname nil 5))))))


I think the original version was attempting to guard against the
possibility of BUFF naming a dead or non-existent buffer, and your
version has lost that feature.



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

* Re: [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
  2010-09-10 21:25 ` Glenn Morris
@ 2010-09-10 21:40   ` Glenn Morris
  2010-09-10 22:43     ` Julien Danjou
  2010-09-13 14:33     ` Julien Danjou
  0 siblings, 2 replies; 6+ messages in thread
From: Glenn Morris @ 2010-09-10 21:40 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

Glenn Morris wrote:

> I think the original version was attempting to guard against the
> possibility of BUFF naming a dead or non-existent buffer, and your
> version has lost that feature.

That was a dumb comment (better to throw an error than do nothing).
I'll install your version.



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

* Re: [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
  2010-09-10 21:40   ` Glenn Morris
@ 2010-09-10 22:43     ` Julien Danjou
  2010-09-13 14:33     ` Julien Danjou
  1 sibling, 0 replies; 6+ messages in thread
From: Julien Danjou @ 2010-09-10 22:43 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

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

On Fri, Sep 10 2010, Glenn Morris wrote:

> That was a dumb comment (better to throw an error than do nothing).

No problem. ;)

> I'll install your version.

Thanks Glenn. :)

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
  2010-09-10 21:40   ` Glenn Morris
  2010-09-10 22:43     ` Julien Danjou
@ 2010-09-13 14:33     ` Julien Danjou
  2010-09-13 16:17       ` Glenn Morris
  1 sibling, 1 reply; 6+ messages in thread
From: Julien Danjou @ 2010-09-13 14:33 UTC (permalink / raw)
  To: Glenn Morris; +Cc: emacs-devel

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

On Fri, Sep 10 2010, Glenn Morris wrote:

> That was a dumb comment (better to throw an error than do nothing).
> I'll install your version.

Glenn, I don't see it. Did you miss it?

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional
  2010-09-13 14:33     ` Julien Danjou
@ 2010-09-13 16:17       ` Glenn Morris
  0 siblings, 0 replies; 6+ messages in thread
From: Glenn Morris @ 2010-09-13 16:17 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

Julien Danjou wrote:

>> I'll install your version.
>
> Glenn, I don't see it. Did you miss it?

Check the emacs-23 branch, and wait for it to be merged to the trunk.



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

end of thread, other threads:[~2010-09-13 16:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08 12:51 [PATCH] url-cache (url-store-in-cache): Make `buff' argument really optional Julien Danjou
2010-09-10 21:25 ` Glenn Morris
2010-09-10 21:40   ` Glenn Morris
2010-09-10 22:43     ` Julien Danjou
2010-09-13 14:33     ` Julien Danjou
2010-09-13 16:17       ` Glenn Morris

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