Re: [O] [RFC] Org Num library

2019-02-03 Thread stardiviner


Nicolas Goaziou  writes:

> Hello,
>
> Marco Wahl  writes:
>
>> Just one idea came to my mind.  What about adding an option to restart
>> the numbering at 1 for the first heading in the case when narrowing is
>> in effect?
>
> AFAICT, detecting narrowing changes requires using
> `post-command-hook'.

Add more things into `post-command-hook' is not a good idea. Org will
really getting slow! I saw many Org Mode newbie complain about Org Mode
slow on big Org file. Myself has this experience often. I have to
disable some features so speedup Org rendering.

Well, I think this is just my personal opinion. I respect author's
decision.

> Therefore an update to numbering, when such change happens, might get in
> the way, e.g., if it slows down input.
>
> Anyway, here is a POC, if anyone wants to test it.
>
> Regards,
>
> -- 
> Nicolas Goaziou
> From 1659484513fd4badb1fca867810a87756d1d46b5 Mon Sep 17 00:00:00 2001
> From: Nicolas Goaziou 
> Date: Sun, 3 Feb 2019 10:33:47 +0100
> Subject: [PATCH] org-num: Add an option to start numbering according to
>  narrowing
>
> * lisp/org-num.el (org-num-visible-only):
> (org-num--start): New variables.
> (org-num--current-numbering): Change signature.
> (org-num--number-region):
> (org-num--update): Apply signature change.
> (org-num--check-narrowing): New function.
> (org-num-mode): Add, or remove, new function in `post-command-hook'.
> ---
>  lisp/org-num.el | 80 -
>  1 file changed, 53 insertions(+), 27 deletions(-)
>
> diff --git a/lisp/org-num.el b/lisp/org-num.el
> index f062526a0..de0a4ad48 100644
> --- a/lisp/org-num.el
> +++ b/lisp/org-num.el
> @@ -135,6 +135,12 @@ control tag inheritance."
>:type 'boolean
>:safe #'booleanp)
>  
> +(defcustom org-num-visible-only nil
> +  "Non-nil restricts numbering to the visible part of the buffer."
> +  :group 'org-appearance
> +  :type 'boolean
> +  :safe #'booleanp)
> +
>  
>  ;;; Internal Variables
>  
> @@ -154,6 +160,9 @@ inheritance of no-numbering attributes.")
>  A numbering is a list of integers, in reverse order.  So numbering
>  for headline \"1.2.3\" is (3 2 1).")
>  
> +(defvar-local org-num--start 1
> +  "Buffer position where headlines start to be numbered.")
> +
>  (defvar-local org-num--missing-overlay nil
>"Buffer position signaling a headline without an overlay.")
>  
> @@ -255,16 +264,22 @@ otherwise."
>   (org-entry-get (point) "UNNUMBERED")
>   t
>  
> -(defun org-num--current-numbering (level skip)
> +(defun org-num--current-numbering (pos level skip)
>"Return numbering for current headline.
> -LEVEL is headline's level, and SKIP its skip value.  Return nil
> -if headline should be skipped."
> +
> +POS is headline's beginning position, LEVEL its level, and SKIP
> +its skip value.
> +
> +Numbering starts from `org-num--start' position.  Return nil if
> +headline should not be numbered."
>(cond
> ;; Skipped by inheritance.
> ((and org-num--skip-level (> level org-num--skip-level)) nil)
> ;; Skipped by a non-nil skip value; set `org-num--skip-level'
> ;; to skip the whole sub-tree later on.
> (skip (setq org-num--skip-level level) nil)
> +   ;; Skipped because it is before visible part of the buffer.
> +   ((and org-num-visible-only (< pos org-num--start)) nil)
> (t
>  (setq org-num--skip-level nil)
>  ;; Compute next numbering, and update `org-num--numbering'.
> @@ -296,10 +311,12 @@ first."
>  (let ((regexp (org-num--headline-regexp))
>(new nil))
>(while (re-search-forward regexp end t)
> -(let* ((level (org-reduced-level
> -   (- (match-end 0) (match-beginning 0) 1)))
> -   (skip (org-num--skip-value))
> -   (numbering (org-num--current-numbering level skip)))
> +(let* ((pos (line-beginning-position))
> +(level (org-reduced-level
> +(- (match-end 0) (match-beginning 0) 1)))
> +(skip (org-num--skip-value))
> +(numbering
> + (org-num--current-numbering pos level skip)))
>;; Apply numbering to current headline.  Store overlay for
>;; the return value.
>(push (org-num--make-overlay numbering level skip)
> @@ -324,26 +341,26 @@ missing overlays to that list."
> ;; last known overlay, make sure to parse the buffer between
> ;; these two overlays.
> ((org-num--valid-overlay-p overlay)
> -(let ((next (overlay-start overlay))
> -  (last (and new-overlays (overlay-start (car new-overlays)
> -  (cond
> -   ((null org-num--missing-overlay))
> -   ((> org-num--missing-overlay next))
> -   ((or (null last) (> org-num--missing-overlay last))
> -(setq org-num--missing-overlay nil)
> -(setq new-overlays (nconc (org-num--number-region last next)
> -  new-overlays)))
> -

[O] (no subject)

2019-02-03 Thread Lawrence Bottorff
At the bottom of this  is
a description of adding a `org-store-link` inside of a babel code block
edit called with C-c ' , however, it doesn't seem to work with C-c l ,
although M-x org-store-line does work. Or am I seeing, doing this wrong?

LB


Re: [O] org-today broken

2019-02-03 Thread Kyle Meyer
Hi Marco,

Marco Wahl  writes:

> Occasionally I like to bend time to see what the agenda would look like
> if another day was current.  This can be achieved conveniently when
> solely function "current-time" is the source for the current time.
>
> So I'm all for using the explicit calls to current-time instead of using
> alternatve sources for the current time.

Sorry for making your time travel harder :]

Emacs's c75f505dea6 argues for replacing current-time calls with nil
where possible because "nil is a bit more efficient and should have less
timing error".  But if there are any particular spots where you'd like
to use current-time for the reasons you give above, please feel free to
make those changes.  (There are already quite a few places where I've
done this because we depend on overriding current-time in tests.)

-- 
Kyle



Re: [O] Bug: org-copy-subtree: Invalid function: org-preserve-local-variables

2019-02-03 Thread Abdo Haji-Ali
I just updated emacs to 27.0.50 and I am seeing the exact same error.
I think org-preserve-local-variables is in org-macs which is part of
org-mode source code.

On Sun, Feb 3, 2019 at 4:14 PM Kyle Meyer  wrote:
>
> Hello,
>
> Abdo Haji-Ali  writes:
>
> > On the latest org-mode version, 9.2, I keep receiving the error
> > 'org-copy-subtree: Invalid function: org-preserve-local-variables'
> > whenever I try to move a subtree or when I access my agenda.
> >
> > This happens even if I run emacs with '-Q'.
> >
> > Emacs  : GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.10)
>
> This is very likely a problem in your Org installation due to an
> interaction with the Org version that comes with Emacs 25.  (It lacks
> the macro org-preserve-local-variables.)
>
> See .



-- 
Abdo Haji-Ali



Re: [O] Org Elpa deployment failing for past 2 weeks

2019-02-03 Thread Bastien
Hi Detlef,

thanks for reporting this -- I manually uploaded the elpa and elpaplus
packages.  Can you check it is okay now?  The process is broken on the
server, I need to investigate a bit to fix it.

Thanks,

-- 
 Bastien



Re: [O] Org 9.2.1 release?

2019-02-03 Thread Bastien
Hello Nicolas,

> If there is no objection, I think it is time for a bugfix release.

Yes, this is done now, Org 9.2.1 is out.

Thanks!

-- 
 Bastien



Re: [O] Closing a task yesterday (or changing the day cutoff to 4am)

2019-02-03 Thread John Lee
Also see variable org-use-effective-time

On Sat, 2 Feb 2019, at 15:30, Leo Gaspard wrote:
> Uwe Koloska  writes:
> > Maybe the variable 'org-extend-today-until' can help.
> 
> Indeed, thank you!
> 



Re: [O] Bug: org-copy-subtree: Invalid function: org-preserve-local-variables

2019-02-03 Thread Kyle Meyer
Hello,

Abdo Haji-Ali  writes:

> On the latest org-mode version, 9.2, I keep receiving the error
> 'org-copy-subtree: Invalid function: org-preserve-local-variables'
> whenever I try to move a subtree or when I access my agenda.
>
> This happens even if I run emacs with '-Q'.
>
> Emacs  : GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.10)

This is very likely a problem in your Org installation due to an
interaction with the Org version that comes with Emacs 25.  (It lacks
the macro org-preserve-local-variables.)

See .



Re: [O] [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days

2019-02-03 Thread John Lee
OK I guess in fact I'm 1. supposed to attach the patches (?) and 2. they 
contain hashes so I guess I should reattach them all together, having changed 
the first.  Here they are.  Sorry, I'm new to this email workflow.

The new thing here since Nicolas reviewed this last year (apart from applying 
changes in response to review feedback) is "greying out" habits that you just 
did, by applying face 'org-agenda-done when a habit is scheduled for the future.

On Sun, 3 Feb 2019, at 16:03, John Lee wrote:
> * lisp/org-habit.el (org-habit-scheduled-past-days): New variable
> 
> * lisp/org-agenda.el (org-agenda-get-scheduled): override
>   `org-scheduled-past-days' for habits if
>   `org-habit-scheduled-past-days` is not nil
> 
> TINYCHANGE
> ---
>  lisp/org-agenda.el |  4 +++-
>  lisp/org-habit.el  | 15 +++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 489ecec95..784a555a9 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -90,6 +90,7 @@
>  (defvar org-habit-show-habits)
>  (defvar org-habit-show-habits-only-for-today)
>  (defvar org-habit-show-all-today)
> +(defvar org-habit-scheduled-past-days)
>  
>  ;; Defined somewhere in this file, but used before definition.
>  (defvar org-agenda-buffer-name "*Org Agenda*")
> @@ -6201,7 +6202,8 @@ scheduled items with an hour specification like 
> [h]h:mm."
>  habitp
>  (bound-and-true-p org-habit-show-all-today))
>   (when (or (and (> ddays 0) (< diff ddays))
> -   (> diff org-scheduled-past-days)
> +   (> diff (or (and habitp org-habit-scheduled-past-days)
> +   org-scheduled-past-days))
> (> schedule current)
> (and (/= current schedule)
>  (/= current today)
> diff --git a/lisp/org-habit.el b/lisp/org-habit.el
> index af4520729..88df38ce0 100644
> --- a/lisp/org-habit.el
> +++ b/lisp/org-habit.el
> @@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
>:group 'org-habit
>:type 'boolean)
>  
> +(defcustom org-habit-scheduled-past-days nil
> +"Value to use instead of `org-scheduled-past-days', for habits only.
> +
> +If nil, `org-scheduled-past-days' is used.
> +
> +Setting this to say 1 is a way to make habits always show up
> +as a reminder, even if you set `org-scheduled-past-days' to a
> +small value because you regard scheduled items as a way of
> +\"turning on\" TODO items on a particular date, rather than as a
> +means of creating calendar-based reminders."
> +  :group 'org-habit
> +  :type '(choice integer (const nil))
> +  :package-version '(Org . "9.3")
> +  :safe (lambda (v) (or (integerp v) (null v
> +
>  (defface org-habit-clear-face
>'background light)) (:background "#8270f9"))
>  (((background dark)) (:background "blue")))
> -- 
> 2.17.1
> 
> 
From 81a56b4b2fd8bfa92695a8386158f6e03584f948 Mon Sep 17 00:00:00 2001
From: John Lee 
Date: Sun, 3 Feb 2019 12:35:39 +
Subject: [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days

* lisp/org-habit.el (org-habit-scheduled-past-days): New variable

* lisp/org-agenda.el (org-agenda-get-scheduled): override
  `org-scheduled-past-days' for habits if
  `org-habit-scheduled-past-days` is not nil

TINYCHANGE
---
 lisp/org-agenda.el |  4 +++-
 lisp/org-habit.el  | 15 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 489ecec95..784a555a9 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -90,6 +90,7 @@
 (defvar org-habit-show-habits)
 (defvar org-habit-show-habits-only-for-today)
 (defvar org-habit-show-all-today)
+(defvar org-habit-scheduled-past-days)
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")
@@ -6201,7 +6202,8 @@ scheduled items with an hour specification like [h]h:mm."
 		   habitp
 		   (bound-and-true-p org-habit-show-all-today))
 	(when (or (and (> ddays 0) (< diff ddays))
-		  (> diff org-scheduled-past-days)
+		  (> diff (or (and habitp org-habit-scheduled-past-days)
+  org-scheduled-past-days))
 		  (> schedule current)
 		  (and (/= current schedule)
 			   (/= current today)
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index af4520729..88df38ce0 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-scheduled-past-days nil
+"Value to use instead of `org-scheduled-past-days', for habits only.
+
+If nil, `org-scheduled-past-days' is used.
+
+Setting this to say 1 is a way to make habits always show up
+as a reminder, even if you set `org-scheduled-past-days' to a
+small value because you regard scheduled items as a way of
+\"turning on\" TODO items on a 

[O] [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days

2019-02-03 Thread John Lee
* lisp/org-habit.el (org-habit-scheduled-past-days): New variable

* lisp/org-agenda.el (org-agenda-get-scheduled): override
  `org-scheduled-past-days' for habits if
  `org-habit-scheduled-past-days` is not nil

TINYCHANGE
---
 lisp/org-agenda.el |  4 +++-
 lisp/org-habit.el  | 15 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 489ecec95..784a555a9 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -90,6 +90,7 @@
 (defvar org-habit-show-habits)
 (defvar org-habit-show-habits-only-for-today)
 (defvar org-habit-show-all-today)
+(defvar org-habit-scheduled-past-days)
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")
@@ -6201,7 +6202,8 @@ scheduled items with an hour specification like [h]h:mm."
   habitp
   (bound-and-true-p org-habit-show-all-today))
(when (or (and (> ddays 0) (< diff ddays))
- (> diff org-scheduled-past-days)
+ (> diff (or (and habitp org-habit-scheduled-past-days)
+ org-scheduled-past-days))
  (> schedule current)
  (and (/= current schedule)
   (/= current today)
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index af4520729..88df38ce0 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-scheduled-past-days nil
+"Value to use instead of `org-scheduled-past-days', for habits only.
+
+If nil, `org-scheduled-past-days' is used.
+
+Setting this to say 1 is a way to make habits always show up
+as a reminder, even if you set `org-scheduled-past-days' to a
+small value because you regard scheduled items as a way of
+\"turning on\" TODO items on a particular date, rather than as a
+means of creating calendar-based reminders."
+  :group 'org-habit
+  :type '(choice integer (const nil))
+  :package-version '(Org . "9.3")
+  :safe (lambda (v) (or (integerp v) (null v
+
 (defface org-habit-clear-face
   'background light)) (:background "#8270f9"))
 (((background dark)) (:background "blue")))
-- 
2.17.1




Re: [O] org-habit: allow overriding org-scheduled-past-days and always including time of day

2019-02-03 Thread John Lee
On Sun, 18 Nov 2018, at 23:40, Nicolas Goaziou wrote:
> * lisp/org-habit.el (org-habit-scheduled-past-days): New variable.
> 
> > (when (or (and (> ddays 0) (< diff ddays))
> > - (> diff org-scheduled-past-days)
> > + (> diff (if habitp
> > + (or org-habit-scheduled-past-days
> > + org-scheduled-past-days)
> > +   org-scheduled-past-days))
> 
> Nitpick:
> 
> (or (and habitp org-habit-scheduled-past-days)
> org-scheduled-past-days)

Oops, I just remembered that 0 is not "falsy" in elisp.  So I'll make this 
change after all and submit that first patch again, again...



[O] Bug: org-copy-subtree: Invalid function: org-preserve-local-variables

2019-02-03 Thread Abdo Haji-Ali
On the latest org-mode version, 9.2, I keep receiving the error
'org-copy-subtree: Invalid function: org-preserve-local-variables'
whenever I try to move a subtree or when I access my agenda.

This happens even if I run emacs with '-Q'.

Emacs  : GNU Emacs 25.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.10)
 of 2017-10-30
Package: Org mode version 9.2 (9.2-43-gf9a8cc-elpa @
/home/ah180/.emacs.d/elpa/org-20190128/)

current state:
==
(setq
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
 org-occur-hook '(org-first-headline-recenter)
 org-src-tab-acts-natively t
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-capture-after-finalize-hook '((lambda nil (org-gcal-sync)))
 org-src-window-setup 'current-window
 org-confirm-shell-link-function 'yes-or-no-p
 org-gcal-file-alist '(("abdo.haji@gmail.com" .
"~/Work/Projects/dropbox-git/gcal.org"))
 org-tab-before-tab-emulation-hook '(org-tempo-complete-tag)
 org-agenda-custom-commands '(("c" "Simple agenda view" ((agenda "")
(alltodo ""
 org-default-notes-file "~/Work/Projects/dropbox-git/tasks.org"
 org-todo-keyword-faces '(("TODO" :foreground "#00" :weight bold
:box (:line-width 1 :style none))
  ("NEXT" :foreground "red" :weight bold :box
(:line-width 1 :style none))
  ("DONE" :foreground "forest green" :weight bold :box
   (:line-width 1 :style none))
  ("WAITING" :foreground "orange" :weight bold :box
   (:line-width 1 :style none))
  ("HOLD" :foreground "cyan" :weight bold :box
(:line-width 1 :style none))
  ("CANCELLED" :foreground "forest green"
:weight bold :box
   (:line-width 1 :style none))
  )
 org-startup-indented t
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-from-is-user-regexp "\\"
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(org-tempo-setup (lambda nil (org-bullets-mode))
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-show-all
append local] 5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook
org-babel-show-result-all append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9))
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-todo-state-tags-triggers '(("CANCELLED" ("CANCELLED" . t))
("WAITING" ("WAITING" . t))
("HOLD" ("WAITING") ("HOLD" . t))
(done ("WAITING") ("HOLD"))
("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
("DONE" ("WAITING") ("CANCELLED") ("HOLD")))
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-directory "~/Work/Projects/dropbox-git/"
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAITING(w)" "|" "DONE(d)")
 (sequence "HOLD(h@/!)" "|" "CANCELLED(c@/!)"))
 org-modules '(org-tempo org-w3m org-bbdb org-bibtex org-docview
org-gnus org-info org-irc org-mhe
   org-rmail org-eww)
 org-capture-before-finalize-hook '(org-gcal--capture-post)
 org-gcal-client-secret "L87mfr8h7vhETM1jRUn9Hdwy"
 org-confirm-elisp-link-function 'yes-or-no-p
 org-gcal-client-id
"543829701868-rl0ndisa6fk111rv0s1vq0eeiu7dfcsa.apps.googleusercontent.com"
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("id" :follow org-id-open) ("eww" :follow eww
:store org-eww-store-link)
   ("rmail" :follow org-rmail-open :store
org-rmail-store-link)
   ("mhe" :follow org-mhe-open :store org-mhe-store-link)
   ("irc" :follow org-irc-visit :store
org-irc-store-link :export org-irc-export)
   ("info" :follow org-info-open :export
org-info-export :store
org-info-store-link)
   ("gnus" :follow org-gnus-open :store org-gnus-store-link)
   ("docview" :follow org-docview-open :export
org-docview-export :store
org-docview-store-link)
   ("bibtex" :follow org-bibtex-open :store
org-bibtex-store-link)
   ("bbdb" :follow org-bbdb-open :export
org-bbdb-export :complete

[O] [PATCH 3/3] org-habit: Use face 'org-agenda-done for habits scheduled for future

2019-02-03 Thread John Lee
* lisp/org-agenda.el (org-agenda-get-scheduled): Use the face.

This has the effect that if you just did the habit, it is "greyed out"
in the agenda.

TINYCHANGE
---
 lisp/org-agenda.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 39ae85f30..17fa3e519 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6165,6 +6165,7 @@ scheduled items with an hour specification like [h]h:mm."
   (diff (- current schedule))
   (warntime (get-text-property (point) 'org-appt-warntime))
   (pastschedp (< schedule today))
+  (futureschedp (> schedule today))
   (habitp (and (fboundp 'org-is-habit-p) (org-is-habit-p)))
   (suppress-delay
(let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
@@ -6285,6 +6286,8 @@ scheduled items with an hour specification like [h]h:mm."
 head level category tags time nil habitp))
   (face (cond ((and (not habitp) pastschedp)
'org-scheduled-previously)
+  ((and habitp futureschedp)
+   'org-agenda-done)
   (todayp 'org-scheduled-today)
   (t 'org-scheduled)))
   (habitp (and habitp (org-habit-parse-todo
-- 
2.17.1




[O] [PATCH 2/3] org-habit: Always show time of day designation for habits

2019-02-03 Thread John Lee
* org-agenda.el (org-agenda-get-scheduled): Always show the time of
  day designation for habits

TINYCHANGE
---
 lisp/org-agenda.el | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 9145cafa8..39ae85f30 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6261,9 +6261,17 @@ scheduled items with an hour specification like [h]h:mm."
   (head (buffer-substring (point) (line-end-position)))
   (time
(cond
-;; No time of day designation if it is only
-;; a reminder.
-((and (/= current schedule) (/= current repeat)) nil)
+;; No time of day designation if it is only a
+;; reminder, except for habits, which always show
+;; the time of day.  Habits are an exception
+;; because if there is a time of day, that is
+;; interpreted to mean they should usually happen
+;; then, even if doing the habit was missed.
+((and
+  (not habitp)
+  (/= current schedule)
+  (/= current repeat))
+ nil)
 ((string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
  (concat (substring s (match-beginning 1)) " "))
 (t 'time)))
-- 
2.17.1




[O] [PATCH 1/3] org-habit: Add org-habit-scheduled-past-days

2019-02-03 Thread John Lee
* lisp/org-habit.el (org-habit-scheduled-past-days): New variable

* lisp/org-agenda.el (org-agenda-get-scheduled): override
  `org-scheduled-past-days' for habits if
  `org-habit-scheduled-past-days` is not nil

TINYCHANGE
---
 lisp/org-agenda.el |  8 +++-
 lisp/org-habit.el  | 15 +++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 489ecec95..9145cafa8 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -90,6 +90,7 @@
 (defvar org-habit-show-habits)
 (defvar org-habit-show-habits-only-for-today)
 (defvar org-habit-show-all-today)
+(defvar org-habit-scheduled-past-days)
 
 ;; Defined somewhere in this file, but used before definition.
 (defvar org-agenda-buffer-name "*Org Agenda*")
@@ -6201,7 +6202,12 @@ scheduled items with an hour specification like [h]h:mm."
   habitp
   (bound-and-true-p org-habit-show-all-today))
(when (or (and (> ddays 0) (< diff ddays))
- (> diff org-scheduled-past-days)
+ (> diff
+(if habitp
+(if (null org-habit-scheduled-past-days)
+org-scheduled-past-days
+  org-habit-scheduled-past-days)
+  org-scheduled-past-days))
  (> schedule current)
  (and (/= current schedule)
   (/= current today)
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index af4520729..88df38ce0 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -89,6 +89,21 @@ It will be green even if it was done after the deadline."
   :group 'org-habit
   :type 'boolean)
 
+(defcustom org-habit-scheduled-past-days nil
+"Value to use instead of `org-scheduled-past-days', for habits only.
+
+If nil, `org-scheduled-past-days' is used.
+
+Setting this to say 1 is a way to make habits always show up
+as a reminder, even if you set `org-scheduled-past-days' to a
+small value because you regard scheduled items as a way of
+\"turning on\" TODO items on a particular date, rather than as a
+means of creating calendar-based reminders."
+  :group 'org-habit
+  :type '(choice integer (const nil))
+  :package-version '(Org . "9.3")
+  :safe (lambda (v) (or (integerp v) (null v
+
 (defface org-habit-clear-face
   'background light)) (:background "#8270f9"))
 (((background dark)) (:background "blue")))
-- 
2.17.1




Re: [O] Mark vacation days

2019-02-03 Thread John Lee
I don't know a good way to do this out of the box.  Here are two ways you could 
go about it, but they both involve a bit of programming.  They would all use 
org-agenda-day-face-function similar to the code you already posted.

1. Least programming: Add emacs diary entries (rather than recording the days 
using org datestamps -- see 
https://www.gnu.org/software/emacs/manual/html_node/emacs/Special-Diary-Entries.html)
 and adapt https://emacs.stackexchange.com/a/45778/5495 to check diary-lib.el 
instead of holidays.el .  Note this won't work by using the support for adding 
diary sexps directly to org files 
(https://orgmode.org/manual/Weekly_002fdaily-agenda.html#Calendar_002fDiary-integration)
 without something extra, because then the diary sexp information is only in 
org, not in the emacs diary itself, so you can't just look in 
diary-entries-list.  All pretty confusing I know.

Untested (!) based on adapting the stack exchange answer above to extend that 
(which pulls in holiday.el holidays + tests whether the day is a weekend -- the 
following is intended to hint how to extend that to pull in diary-lib.el dates 
too):

Note I'm guessing you'd have to set org-agenda-include-diary for this to work, 
but I have not tested this *at all*, so this really is all just a hint.  Also, 
watch out for the weird dependence of diary-lib.el on calendar-date-style.

(defface my/org-agenda-holiday '((t (:inherit default)))
  "Base face used in agenda for holidays, whether today's date or not."
  :group 'org-faces)
(defface my/org-agenda-holiday-not-today '((t (:inherit (my/org-agenda-holiday 
org-agenda-date
  "Face used in agenda for holidays other than for today's date."
  :group 'org-faces)
(defface my/org-agenda-holiday-today '((t (:inherit (my/org-agenda-holiday 
org-agenda-date-today
  "Face used in agenda for holidays for today's date."
  :group 'org-faces)

(defun my/in-diary-p (date)
  (car (alist-get date diary-entries-list nil nil #'equal)))

(defun my/day-face (day)
  (let* ((abs (calendar-absolute-from-gregorian day))
 (todayp (org-agenda-today-p abs))
 (day-of-week (calendar-day-of-week day))
 (holidayp (or
(= day-of-week 0) (= day-of-week 6)
(holiday-in-range abs abs)
(my/in-diary-p day
(cond ((and todayp holidayp) 'my/org-agenda-holiday-today)
  (holidayp 'my/org-agenda-holiday-not-today)
  (todayp 'org-agenda-date-today)
  (t 'org-agenda-date
(setq org-agenda-day-face-function #'my/day-face)


2. Maybe nicer: write something similar to org-agenda-to-appt that generates a 
list of holiday days rather than appointments, then run that code from places 
like 'after-save-hook.  Then consult that list in your 
org-agenda-day-face-function.

On Sun, 27 Jan 2019, at 20:41, JRSS wrote:
> What if you set the category in the function? So the function has 
> something like cond (( or (org-category vacation) (org-category f_event)
> (background: red))
> 
> I obviously don't know how to write it, but the idea is that the 
> categories are already set in the function. I won't have many, three 
> tops, and I won't change them often -- no need to be fully dynamic.
> 
> Sent from ProtonMail mobile
> 
>  Original Message 
> On Jan 27, 2019, 15:35, Ken Mankoff wrote:
> 
> > Hi,
> >
> > On 2019-01-27 at 12:20 -0800, JRSS  wrote...
> >> This is a bit over my head still. I'm trying to wrap my head around it.
> >>
> >> I see what it does (colors day-of-the-week 1 and day-of-the-week-3,
> >> which are Monday and Wednesday, red) but not sure how to tie it to a
> >> category (so say, category "vacation" would be red).
> >>
> >> Once I have the function do that, I can go in and change it so that
> >> different categories will be different colors.
> >
> > It's a bit over my head for this use case too. Sorry. When I saw it I 
> > thought the use case was a list of holidays, which is easier to implement. 
> > You could maintain this list in an easy-to-access format as a variable near 
> > where you implement this function. A dynamic list based on tagged Org items 
> > is certainly more complicated.
> >
> > -k.



[O] Org 9.2.1 release?

2019-02-03 Thread Nicolas Goaziou
Hello,

If there is no objection, I think it is time for a bugfix release.

Bastien, WDYT?

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH] Add feature to org-drill to auto pronounce word

2019-02-03 Thread Nicolas Goaziou
Hello,

Stig Brautaset  writes:

> stardiviner  writes:
>
> [...]
>
>> @@ -1486,7 +1521,7 @@ the current topic."
>>  (funcall test))
>>   (hide-subtree))
>> (push (point) drill-sections)))
>> -   "" 'tree))
>> +   nil 'tree))
>>  (reverse drill-sections)))
>
> Could we have this part of the patch applied separately? org-drill on
> Org 9.2 doesn't work for me without it. Other people have this problem
> too, as I found a reference to this fix here:
> https://emacs.stackexchange.com/a/46961/10625

I applied the whole thing (the fix plus the feature).

Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] latest org-mode ignores visibility property selectively

2019-02-03 Thread Nicolas Goaziou
Hello,

Michael Maurer  writes:

> Ok, I figured it out. If the top headline has a "visibility: folded"
> property, and one of its children has that property as well, the
> parents property gets disabled, for some reason. Guess it's a bug?

Fixed. Thank you!

Regards,

-- 
Nicolas Goaziou



Re: [O] [RFC] Org Num library

2019-02-03 Thread Nicolas Goaziou
Hello,

Marco Wahl  writes:

> Just one idea came to my mind.  What about adding an option to restart
> the numbering at 1 for the first heading in the case when narrowing is
> in effect?

AFAICT, detecting narrowing changes requires using `post-command-hook'.
Therefore an update to numbering, when such change happens, might get in
the way, e.g., if it slows down input.

Anyway, here is a POC, if anyone wants to test it.

Regards,

-- 
Nicolas Goaziou
>From 1659484513fd4badb1fca867810a87756d1d46b5 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou 
Date: Sun, 3 Feb 2019 10:33:47 +0100
Subject: [PATCH] org-num: Add an option to start numbering according to
 narrowing

* lisp/org-num.el (org-num-visible-only):
(org-num--start): New variables.
(org-num--current-numbering): Change signature.
(org-num--number-region):
(org-num--update): Apply signature change.
(org-num--check-narrowing): New function.
(org-num-mode): Add, or remove, new function in `post-command-hook'.
---
 lisp/org-num.el | 80 -
 1 file changed, 53 insertions(+), 27 deletions(-)

diff --git a/lisp/org-num.el b/lisp/org-num.el
index f062526a0..de0a4ad48 100644
--- a/lisp/org-num.el
+++ b/lisp/org-num.el
@@ -135,6 +135,12 @@ control tag inheritance."
   :type 'boolean
   :safe #'booleanp)
 
+(defcustom org-num-visible-only nil
+  "Non-nil restricts numbering to the visible part of the buffer."
+  :group 'org-appearance
+  :type 'boolean
+  :safe #'booleanp)
+
 
 ;;; Internal Variables
 
@@ -154,6 +160,9 @@ inheritance of no-numbering attributes.")
 A numbering is a list of integers, in reverse order.  So numbering
 for headline \"1.2.3\" is (3 2 1).")
 
+(defvar-local org-num--start 1
+  "Buffer position where headlines start to be numbered.")
+
 (defvar-local org-num--missing-overlay nil
   "Buffer position signaling a headline without an overlay.")
 
@@ -255,16 +264,22 @@ otherwise."
  (org-entry-get (point) "UNNUMBERED")
  t
 
-(defun org-num--current-numbering (level skip)
+(defun org-num--current-numbering (pos level skip)
   "Return numbering for current headline.
-LEVEL is headline's level, and SKIP its skip value.  Return nil
-if headline should be skipped."
+
+POS is headline's beginning position, LEVEL its level, and SKIP
+its skip value.
+
+Numbering starts from `org-num--start' position.  Return nil if
+headline should not be numbered."
   (cond
;; Skipped by inheritance.
((and org-num--skip-level (> level org-num--skip-level)) nil)
;; Skipped by a non-nil skip value; set `org-num--skip-level'
;; to skip the whole sub-tree later on.
(skip (setq org-num--skip-level level) nil)
+   ;; Skipped because it is before visible part of the buffer.
+   ((and org-num-visible-only (< pos org-num--start)) nil)
(t
 (setq org-num--skip-level nil)
 ;; Compute next numbering, and update `org-num--numbering'.
@@ -296,10 +311,12 @@ first."
 (let ((regexp (org-num--headline-regexp))
   (new nil))
   (while (re-search-forward regexp end t)
-(let* ((level (org-reduced-level
-   (- (match-end 0) (match-beginning 0) 1)))
-   (skip (org-num--skip-value))
-   (numbering (org-num--current-numbering level skip)))
+(let* ((pos (line-beginning-position))
+	   (level (org-reduced-level
+		   (- (match-end 0) (match-beginning 0) 1)))
+	   (skip (org-num--skip-value))
+	   (numbering
+		(org-num--current-numbering pos level skip)))
   ;; Apply numbering to current headline.  Store overlay for
   ;; the return value.
   (push (org-num--make-overlay numbering level skip)
@@ -324,26 +341,26 @@ missing overlays to that list."
;; last known overlay, make sure to parse the buffer between
;; these two overlays.
((org-num--valid-overlay-p overlay)
-(let ((next (overlay-start overlay))
-  (last (and new-overlays (overlay-start (car new-overlays)
-  (cond
-   ((null org-num--missing-overlay))
-   ((> org-num--missing-overlay next))
-   ((or (null last) (> org-num--missing-overlay last))
-(setq org-num--missing-overlay nil)
-(setq new-overlays (nconc (org-num--number-region last next)
-  new-overlays)))
-   ;; If it is already after the last known overlay, reset it:
-   ;; some previous invalid overlay already triggered the
-   ;; necessary parsing.
-   (t
-(setq org-num--missing-overlay nil
-;; Update OVERLAY's numbering.
-(let* ((level (overlay-get overlay 'level))
-   (skip (overlay-get overlay 'skip))
-   (numbering (org-num--current-numbering level skip)))
-  (org-num--refresh-display overlay numbering)
-  (push overlay new-overlays)))
+(let ((next (overlay-start overlay)))
+	  (let ((last (and new-overlays