emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-habit config tinypatch
@ 2012-09-17 10:42 Robert Horn
  2012-09-17 17:02 ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Horn @ 2012-09-17 10:42 UTC (permalink / raw)
  To: Org-mode

This patch fixes my problem, but indicates that there is a startup
sequencing issue that may also affect other parts of org.  

First the patch

--- org-agenda.el~	2012-09-12 21:24:27.000000000 -0400
+++ org-agenda.el	2012-09-17 06:02:45.000000000 -0400
@@ -90,7 +90,7 @@
 (defvar org-mobile-force-id-on-agenda-items)  ; defined in org-mobile.el
 (defvar org-habit-show-habits)                ; defined in org-habit.el
 (defvar org-habit-show-habits-only-for-today)
-(defvar org-habit-show-all-today nil)
+(defvar org-habit-show-all-today)             ; defined in org-habit.el
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")

Second, the symptom

Without this patch the emacs config shows the "show-all-today" as having
been changed outside the config process, and it is set to "nil" rather
than the setting in the .emacs file.  It shows this immediately upon
startup when the config option is started and nothing else has been done.

If I understand defvar properly, this means that the org-agenda is being
evaluated before the .emacs, which is not what I expected at all.  So
either I don't understand defvar properly or the order of evaluation at
startup is not what I thought.  Either way, there are possibly other
defvars that need fixing.

Now that org-habit is part of the base org-mode, perhaps the proper fix
is to remove those three defvars.  Someone who understands the startup
sequence should make that decision.

R Horn 
rjhorn@alum.mit.edu

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

* Re: org-habit config tinypatch
  2012-09-17 10:42 org-habit config tinypatch Robert Horn
@ 2012-09-17 17:02 ` Bastien
  2012-09-18 16:47   ` Robert Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2012-09-17 17:02 UTC (permalink / raw)
  To: Robert Horn; +Cc: Org-mode

Hi Robert,

Robert Horn <rjhorn@alum.mit.edu> writes:

> This patch fixes my problem, but indicates that there is a startup
> sequencing issue that may also affect other parts of org.  
>
> First the patch
>
> --- org-agenda.el~	2012-09-12 21:24:27.000000000 -0400
> +++ org-agenda.el	2012-09-17 06:02:45.000000000 -0400
> @@ -90,7 +90,7 @@
>  (defvar org-mobile-force-id-on-agenda-items)  ; defined in org-mobile.el
>  (defvar org-habit-show-habits)                ; defined in org-habit.el
>  (defvar org-habit-show-habits-only-for-today)
> -(defvar org-habit-show-all-today nil)
> +(defvar org-habit-show-all-today)             ; defined in org-habit.el
>  
>  ;; Defined somewhere in this file, but used before definition.
>  (defvar org-agenda-buffer-name "*Org Agenda*")

Thanks.

I've applied a patch that does not (defvar ... nil), since we only
defvar here to silent the byte-compiler, not to initialize the var.
The rest of my change check whether the variable has been already
initialized (boundp '...) so that the agenda does not choke.

> Second, the symptom
>
> Without this patch the emacs config shows the "show-all-today" as having
> been changed outside the config process, and it is set to "nil" rather
> than the setting in the .emacs file.  It shows this immediately upon
> startup when the config option is started and nothing else has been done.
>
> If I understand defvar properly, this means that the org-agenda is being
> evaluated before the .emacs, which is not what I expected at all.  So
> either I don't understand defvar properly or the order of evaluation at
> startup is not what I thought.  Either way, there are possibly other
> defvars that need fixing.
>
> Now that org-habit is part of the base org-mode, perhaps the proper fix
> is to remove those three defvars.  Someone who understands the startup
> sequence should make that decision.

This is weird.  If the variable has been set through .emacs.el or the
.emacs-custom.el file at startup, then defvar'ing it to nil should not
do anything.

(setq ahem 3)        => 3
(defvar ahem nil)    => ahem
(eval ahem)          => 3

If you don't have the above results, perhaps you should report this as
an Emacs bug.

Thanks,

-- 
 Bastien

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

* Re: org-habit config tinypatch
  2012-09-17 17:02 ` Bastien
@ 2012-09-18 16:47   ` Robert Horn
  2012-09-19  8:16     ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Horn @ 2012-09-18 16:47 UTC (permalink / raw)
  To: Bastien; +Cc: Org-mode

I found the issue, and it's a more subtle one.  I've set a bug to emacs
list in case they think it's a documentation or fixable bug.  What
happens is this:

    - The custom value setting for org options do not take effect until *after* the relevant lisp code has been executed once.  This means:
    - If you start emacs and immediately go into *scratch* and print org-habit-show-today-all you get an error because that variable has not yet been bound.
: Debugger entered--Lisp error: (void-variable org-habit-show-all-today)
:   (print org-habit-show-all-today)
:   eval((print org-habit-show-all-today) nil)
:   eval-last-sexp-1(t)
:   eval-last-sexp(t)
:   eval-print-last-sexp()
:   call-interactively(eval-print-last-sexp nil nil) 
    - If you start emacs and immediately go into options->config for org-habit, the org-habit-show-today-all will indicate that it has been set outside of the customization system when the intended value is "t".  When the intended value is "nil" there is no indicated problem.
    - If you start emacs and put a buffer into org mode, the (print org-habit-show-all) will show the customized value, and the options->config will also show the customized value.

I think that this is either a documentation bug, where this behavior
needs explaining, or a bug in customize.  As a naive user of customize I
would expect that going to the org-habit group would automatically
trigger applying the org-habit customizations.  Opening an org-mode
buffer has this effect.

But, perhaps there is some flag somewhere well hidden in the
documentation for customization groups that needs to be set to indicate
this.

R Horn
rjhorn@alum.mit.edu

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

* Re: org-habit config tinypatch
  2012-09-18 16:47   ` Robert Horn
@ 2012-09-19  8:16     ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2012-09-19  8:16 UTC (permalink / raw)
  To: Robert Horn; +Cc: Org-mode

Hi Robert,

Robert Horn <rjhorn@alum.mit.edu> writes:

> As a naive user of customize I
> would expect that going to the org-habit group would automatically
> trigger applying the org-habit customizations.

It triggers the org-habit customizations as set from org-habit.el
through all the defcustoms, not from your .emacs.el file.

To trigger the customizations of your .emacs.el file you have to load
your .emacs file and your custom file (C-h v custom-file RET).

When loading .emacs, if some org-habit values differ from their default
values in org-habit.el, they will be advertized as changed outside the
customize interface.

I'm not sure I get what's not intuitive here :)

-- 
 Bastien

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

end of thread, other threads:[~2012-09-19  8:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 10:42 org-habit config tinypatch Robert Horn
2012-09-17 17:02 ` Bastien
2012-09-18 16:47   ` Robert Horn
2012-09-19  8:16     ` Bastien

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