emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* PATCH:  Fix for agenda problems
@ 2010-07-29 23:21 Robert Goldman
  2010-08-01 18:28 ` David Maus
  2010-08-01 18:28 ` PATCH: Fix for agenda problems David Maus
  0 siblings, 2 replies; 8+ messages in thread
From: Robert Goldman @ 2010-07-29 23:21 UTC (permalink / raw)
  To: Org Mode

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

As far as I can tell, the current version of org-write-agenda evaluates
ps-print-buffer-with-faces too eagerly.  I tripped over this because
aquamacs 2.0, which I'm using, seems to have ps-printing code that
conflicts with org-mode's expectation.

The attached patch tries to fix this, but does not do the job
particularly elegantly.  Instead of EVALUATING the flet form, it
MACROEXPANDS that form, which I believe is correct in this context.

Please have a look at the patch and test it.

I believe you should be able to verify this problem with the git head by
doing something like:

1.  (fmakunbound 'ps-print-buffer-with-faces)

2.  push the mobile org agendas

If I am correct, then pushing the mobile org agendas, which does NOT
involve writing any postscript, will crash, because the
ps-print-buffer-with-faces will be called.

best,
r

PS I am not sure what the rules are about attachments on this mailing
list, so I am both attaching the patch and inserting it as text  below.


From 6bc0ba91667f84be9b7e334c517dad72f6eb277f Mon Sep 17 00:00:00 2001
From: Robert P. Goldman <rpgoldman@real-time.com>
Date: Thu, 29 Jul 2010 18:11:21 -0500
Subject: [PATCH] Fixed macroexpansion bug for FLET in org-write-agenda

---
 lisp/org-agenda.el |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d62b193..b694ff3 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2486,14 +2486,16 @@ higher priority settings."
 	       (message "HTML written to %s" file))
 	      ((string-match "\\.ps\\'" file)
 	       (require 'ps-print)
-	       ,(flet ((ps-get-buffer-name () "Agenda View"))
-		  (ps-print-buffer-with-faces file))
+	       ,(macroexpand
+		 '(flet ((ps-get-buffer-name () "Agenda View"))
+		    (ps-print-buffer-with-faces file)))
 	       (message "Postscript written to %s" file))
 	      ((string-match "\\.pdf\\'" file)
 	       (require 'ps-print)
-	       ,(flet ((ps-get-buffer-name () "Agenda View"))
-		  (ps-print-buffer-with-faces
-		   (concat (file-name-sans-extension file) ".ps")))
+	       ,(macroexpand
+			'(flet ((ps-get-buffer-name () "Agenda View"))
+			  (ps-print-buffer-with-faces
+			   (concat (file-name-sans-extension file) ".ps"))))
 	       (call-process "ps2pdf" nil nil nil
 			     (expand-file-name
 			      (concat (file-name-sans-extension file) ".ps"))
-- 
1.7.1


[-- Attachment #2: 0001-Fixed-macroexpansion-bug-for-FLET-in-org-write-agend.patch --]
[-- Type: text/plain, Size: 1409 bytes --]

From 6bc0ba91667f84be9b7e334c517dad72f6eb277f Mon Sep 17 00:00:00 2001
From: Robert P. Goldman <rpgoldman@real-time.com>
Date: Thu, 29 Jul 2010 18:11:21 -0500
Subject: [PATCH] Fixed macroexpansion bug for FLET in org-write-agenda

---
 lisp/org-agenda.el |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index d62b193..b694ff3 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2486,14 +2486,16 @@ higher priority settings."
 	       (message "HTML written to %s" file))
 	      ((string-match "\\.ps\\'" file)
 	       (require 'ps-print)
-	       ,(flet ((ps-get-buffer-name () "Agenda View"))
-		  (ps-print-buffer-with-faces file))
+	       ,(macroexpand
+		 '(flet ((ps-get-buffer-name () "Agenda View"))
+		    (ps-print-buffer-with-faces file)))
 	       (message "Postscript written to %s" file))
 	      ((string-match "\\.pdf\\'" file)
 	       (require 'ps-print)
-	       ,(flet ((ps-get-buffer-name () "Agenda View"))
-		  (ps-print-buffer-with-faces
-		   (concat (file-name-sans-extension file) ".ps")))
+	       ,(macroexpand
+			'(flet ((ps-get-buffer-name () "Agenda View"))
+			  (ps-print-buffer-with-faces
+			   (concat (file-name-sans-extension file) ".ps"))))
 	       (call-process "ps2pdf" nil nil nil
 			     (expand-file-name
 			      (concat (file-name-sans-extension file) ".ps"))
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: PATCH:  Fix for agenda problems
  2010-07-29 23:21 PATCH: Fix for agenda problems Robert Goldman
@ 2010-08-01 18:28 ` David Maus
  2010-08-02  1:42   ` Robert Goldman
  2010-08-01 18:28 ` PATCH: Fix for agenda problems David Maus
  1 sibling, 1 reply; 8+ messages in thread
From: David Maus @ 2010-08-01 18:28 UTC (permalink / raw)
  To: rpgoldman; +Cc: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 879 bytes --]

Robert Goldman wrote:
>[1  <text/plain; ISO-8859-1 (7bit)>]
>As far as I can tell, the current version of org-write-agenda evaluates
>ps-print-buffer-with-faces too eagerly.  I tripped over this because
>aquamacs 2.0, which I'm using, seems to have ps-printing code that
>conflicts with org-mode's expectation.

>The attached patch tries to fix this, but does not do the job
>particularly elegantly.  Instead of EVALUATING the flet form, it
>MACROEXPANDS that form, which I believe is correct in this context.

Yes, the intension of backquoting the flet macro was macroexpansion,
not evaluation.  And it should work to solve the issue with cl not
loaded on runtime when calling `org-agenda-write'[1].

Best,
  -- David

[1] Cf. http://thread.gmane.org/gmane.emacs.orgmode/26132/focus=26698
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

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

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: PATCH:  Fix for agenda problems
  2010-07-29 23:21 PATCH: Fix for agenda problems Robert Goldman
  2010-08-01 18:28 ` David Maus
@ 2010-08-01 18:28 ` David Maus
  1 sibling, 0 replies; 8+ messages in thread
From: David Maus @ 2010-08-01 18:28 UTC (permalink / raw)
  To: rpgoldman; +Cc: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 879 bytes --]

Robert Goldman wrote:
>[1  <text/plain; ISO-8859-1 (7bit)>]
>As far as I can tell, the current version of org-write-agenda evaluates
>ps-print-buffer-with-faces too eagerly.  I tripped over this because
>aquamacs 2.0, which I'm using, seems to have ps-printing code that
>conflicts with org-mode's expectation.

>The attached patch tries to fix this, but does not do the job
>particularly elegantly.  Instead of EVALUATING the flet form, it
>MACROEXPANDS that form, which I believe is correct in this context.

Yes, the intension of backquoting the flet macro was macroexpansion,
not evaluation.  And it should work to solve the issue with cl not
loaded on runtime when calling `org-agenda-write'[1].

Best,
  -- David

[1] Cf. http://thread.gmane.org/gmane.emacs.orgmode/26132/focus=26698
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

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

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: PATCH:  Fix for agenda problems
  2010-08-01 18:28 ` David Maus
@ 2010-08-02  1:42   ` Robert Goldman
  2010-08-02 16:53     ` David Maus
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Goldman @ 2010-08-02  1:42 UTC (permalink / raw)
  To: David Maus; +Cc: Org Mode

On 8/1/10 Aug 1 -1:28 PM, David Maus wrote:
> Robert Goldman wrote:
>> [1  <text/plain; ISO-8859-1 (7bit)>]
>> As far as I can tell, the current version of org-write-agenda evaluates
>> ps-print-buffer-with-faces too eagerly.  I tripped over this because
>> aquamacs 2.0, which I'm using, seems to have ps-printing code that
>> conflicts with org-mode's expectation.
> 
>> The attached patch tries to fix this, but does not do the job
>> particularly elegantly.  Instead of EVALUATING the flet form, it
>> MACROEXPANDS that form, which I believe is correct in this context.
> 
> Yes, the intension of backquoting the flet macro was macroexpansion,
> not evaluation.  And it should work to solve the issue with cl not
> loaded on runtime when calling `org-agenda-write'[1].
> 
> Best,
>   -- David
> 
> [1] Cf. http://thread.gmane.org/gmane.emacs.orgmode/26132/focus=26698

Are you sure that my patch will work properly?  I was looking at it, and
it seems like the use of org-let might cause the list (the code) to be
evaluated at run-time, and not at compile time, right?

Here's org-let:

(defun org-let (list &rest body)
  (eval (cons 'let (cons list body))))
(put 'org-let 'lisp-indent-function 1)

It occurs in org-agenda.  Question:  does this mean that the backquoted
expression will be evaluated at run-time, or is the compiler aggressive
enough to do it at compile-time?  This is something I /should/ know, but
don't....

best,
r

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

* Re: PATCH:  Fix for agenda problems
  2010-08-02  1:42   ` Robert Goldman
@ 2010-08-02 16:53     ` David Maus
  2010-08-12 16:31       ` [PATCH] Remove dependency of flet in org-write-agenda David Maus
  2010-08-12 16:31       ` [PATCH] Rename temporary buffer to remove dependency of `flet' macro David Maus
  0 siblings, 2 replies; 8+ messages in thread
From: David Maus @ 2010-08-02 16:53 UTC (permalink / raw)
  To: rpgoldman; +Cc: Org Mode


[-- Attachment #1.1: Type: text/plain, Size: 2475 bytes --]

Robert Goldman wrote:
>On 8/1/10 Aug 1 -1:28 PM, David Maus wrote:
>> Robert Goldman wrote:
>>> [1  <text/plain; ISO-8859-1 (7bit)>]
>>> As far as I can tell, the current version of org-write-agenda evaluates
>>> ps-print-buffer-with-faces too eagerly.  I tripped over this because
>>> aquamacs 2.0, which I'm using, seems to have ps-printing code that
>>> conflicts with org-mode's expectation.
>>
>>> The attached patch tries to fix this, but does not do the job
>>> particularly elegantly.  Instead of EVALUATING the flet form, it
>>> MACROEXPANDS that form, which I believe is correct in this context.
>>
>> Yes, the intension of backquoting the flet macro was macroexpansion,
>> not evaluation.  And it should work to solve the issue with cl not
>> loaded on runtime when calling `org-agenda-write'[1].
>>
>> Best,
>>   -- David
>>
>> [1] Cf. http://thread.gmane.org/gmane.emacs.orgmode/26132/focus=26698

>Are you sure that my patch will work properly?  I was looking at it, and
>it seems like the use of org-let might cause the list (the code) to be
>evaluated at run-time, and not at compile time, right?

AFAIK this is the case: The list is passed to org-let and evaluated
there at run-time.  The backquotes were introduced to solve this
issue: A user might run `org-write-agenda' at a point where cl hasn't
be loaded (run-time dependency on cl.el).  Because the whole lisp
structure is passed as a quoted list to org-let, the byte compiler
does not touch it.  If it is evaluated at run-time and cl.el is not
loaded, `flet' is not fbound and `org-write-agenda' fails.

Writing this I realize that the original patch (using backquotes) as
well as the proposed patch using `macroexpand' does /not/ solve this
issue completely: It solves it for running byte-compiled Org, but not
non-byte-compiled Org.

>It occurs in org-agenda.  Question:  does this mean that the backquoted
>expression will be evaluated at run-time, or is the compiler aggressive
>enough to do it at compile-time?

The backquoted expression will be evaluated at compile-time.
Backquoting `flet' removes the run-time dependency on cl.el for byte
compiled code
(http://thread.gmane.org/gmane.emacs.orgmode/26132/focus=26698).

IMO using backquoted `macroexpand' is the way to go.  I'll see if it
works as advertised (e.g. not causing org-write-agenda to fail when
run from byte compiled Org).

Best,
  -- David

--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de

[-- Attachment #1.2: Type: application/pgp-signature, Size: 230 bytes --]

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

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* [PATCH] Remove dependency of flet in org-write-agenda
  2010-08-02 16:53     ` David Maus
@ 2010-08-12 16:31       ` David Maus
  2010-08-12 16:31       ` [PATCH] Rename temporary buffer to remove dependency of `flet' macro David Maus
  1 sibling, 0 replies; 8+ messages in thread
From: David Maus @ 2010-08-12 16:31 UTC (permalink / raw)
  To: emacs-orgmode

This one supersedes patch #181: For reasons not yet know to me using
the proposed `macroexpand' to get the flet macro expanded at compile
time didn't work.

Attached patch solves the whole issue by simply removing the
dependency of `flet' in this function altogether.  It was used to
temporarily redefine the function `ps-print-get-buffer-name' to
enforce the buffer name "Agenda View" (vs. "*temp*" for a temporary
buffer.  So, why not simply rename the temp buffer?

Note: The function `rename-buffer' is called with UNIQUE beeing
non-nil -- just in case there might be a buffer called "*Agenda
View*".

Best,
  -- David

David Maus (1):
  Rename temporary buffer to remove dependency of `flet' macro

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

* [PATCH] Rename temporary buffer to remove dependency of `flet' macro
  2010-08-02 16:53     ` David Maus
  2010-08-12 16:31       ` [PATCH] Remove dependency of flet in org-write-agenda David Maus
@ 2010-08-12 16:31       ` David Maus
  2010-08-18  8:43         ` Carsten Dominik
  1 sibling, 1 reply; 8+ messages in thread
From: David Maus @ 2010-08-12 16:31 UTC (permalink / raw)
  To: emacs-orgmode

* org-agenda.el (org-write-agenda): Rename temporary buffer to remove
dependency of `flet' macro.
---
 lisp/org-agenda.el |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 61b867b..f2592ad 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2454,12 +2454,14 @@ higher priority settings."
    ((string-match "\\.html?\\'" file) (require 'htmlize))
    ((string-match "\\.ps\\'" file) (require 'ps-print)))
   (org-let (if nosettings nil org-agenda-exporter-settings)
-    `(save-excursion
+    '(save-excursion
        (save-window-excursion
 	 (org-agenda-mark-filtered-text)
 	 (let ((bs (copy-sequence (buffer-string))) beg)
 	   (org-agenda-unmark-filtered-text)
 	   (with-temp-buffer
+	     (rename-buffer "Agenda View" t)
+	     (set-buffer-modified-p nil)
 	     (insert bs)
 	     (org-agenda-remove-marked-text 'org-filtered)
 	     (while (setq beg (text-property-any (point-min) (point-max)
@@ -2486,14 +2488,12 @@ higher priority settings."
 	       (message "HTML written to %s" file))
 	      ((string-match "\\.ps\\'" file)
 	       (require 'ps-print)
-	       ,(flet ((ps-get-buffer-name () "Agenda View"))
-		  (ps-print-buffer-with-faces file))
+	       (ps-print-buffer-with-faces file)
 	       (message "Postscript written to %s" file))
 	      ((string-match "\\.pdf\\'" file)
 	       (require 'ps-print)
-	       ,(flet ((ps-get-buffer-name () "Agenda View"))
-		  (ps-print-buffer-with-faces
-		   (concat (file-name-sans-extension file) ".ps")))
+	       (ps-print-buffer-with-faces
+		(concat (file-name-sans-extension file) ".ps"))
 	       (call-process "ps2pdf" nil nil nil
 			     (expand-file-name
 			      (concat (file-name-sans-extension file) ".ps"))
-- 
1.7.1

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

* Re: [PATCH] Rename temporary buffer to remove dependency of `flet' macro
  2010-08-12 16:31       ` [PATCH] Rename temporary buffer to remove dependency of `flet' macro David Maus
@ 2010-08-18  8:43         ` Carsten Dominik
  0 siblings, 0 replies; 8+ messages in thread
From: Carsten Dominik @ 2010-08-18  8:43 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode

Hi David,

I trust that you will apply this patch once you are satisfied with it.

Best wishes

- Carsten

On Aug 12, 2010, at 6:31 PM, David Maus wrote:

> * org-agenda.el (org-write-agenda): Rename temporary buffer to remove
> dependency of `flet' macro.
> ---
> lisp/org-agenda.el |   12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 61b867b..f2592ad 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -2454,12 +2454,14 @@ higher priority settings."
>    ((string-match "\\.html?\\'" file) (require 'htmlize))
>    ((string-match "\\.ps\\'" file) (require 'ps-print)))
>   (org-let (if nosettings nil org-agenda-exporter-settings)
> -    `(save-excursion
> +    '(save-excursion
>        (save-window-excursion
> 	 (org-agenda-mark-filtered-text)
> 	 (let ((bs (copy-sequence (buffer-string))) beg)
> 	   (org-agenda-unmark-filtered-text)
> 	   (with-temp-buffer
> +	     (rename-buffer "Agenda View" t)
> +	     (set-buffer-modified-p nil)
> 	     (insert bs)
> 	     (org-agenda-remove-marked-text 'org-filtered)
> 	     (while (setq beg (text-property-any (point-min) (point-max)
> @@ -2486,14 +2488,12 @@ higher priority settings."
> 	       (message "HTML written to %s" file))
> 	      ((string-match "\\.ps\\'" file)
> 	       (require 'ps-print)
> -	       ,(flet ((ps-get-buffer-name () "Agenda View"))
> -		  (ps-print-buffer-with-faces file))
> +	       (ps-print-buffer-with-faces file)
> 	       (message "Postscript written to %s" file))
> 	      ((string-match "\\.pdf\\'" file)
> 	       (require 'ps-print)
> -	       ,(flet ((ps-get-buffer-name () "Agenda View"))
> -		  (ps-print-buffer-with-faces
> -		   (concat (file-name-sans-extension file) ".ps")))
> +	       (ps-print-buffer-with-faces
> +		(concat (file-name-sans-extension file) ".ps"))
> 	       (call-process "ps2pdf" nil nil nil
> 			     (expand-file-name
> 			      (concat (file-name-sans-extension file) ".ps"))
> -- 
> 1.7.1
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

end of thread, other threads:[~2010-08-19 18:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-29 23:21 PATCH: Fix for agenda problems Robert Goldman
2010-08-01 18:28 ` David Maus
2010-08-02  1:42   ` Robert Goldman
2010-08-02 16:53     ` David Maus
2010-08-12 16:31       ` [PATCH] Remove dependency of flet in org-write-agenda David Maus
2010-08-12 16:31       ` [PATCH] Rename temporary buffer to remove dependency of `flet' macro David Maus
2010-08-18  8:43         ` Carsten Dominik
2010-08-01 18:28 ` PATCH: Fix for agenda problems David Maus

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).