[PATCH] org-agenda: Allow org-agenda-overriding-header to be a function

2021-08-12 Thread Christopher League
* org-agenda.el (org-agenda--insert-overriding-header): Allow
`org-agenda-overriding-header' to be a function in addition to a
string or nil. When the custom agenda is created or updated, call that
function and insert the string it returns as the agenda header.

This allows custom commands to produce dynamic headers that include
up-to-date information. For example, this produces a header with a
current timestamp:

(push '("DHD" "Dynamic header demo"
((alltodo
  ""
  ((org-agenda-overriding-header
(lambda ()
  (propertize
   (format-time-string "-- Get crackin’, it’s %H:%M:%S!!\n")
   'face 'org-agenda-structure)))
  org-agenda-custom-commands)

User is free to add any face properties, use Org links, and include a
blank line or not. I am using this to count how many items are in
various inboxes and display them in an agenda.
---
 lisp/org-agenda.el | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b4e5547d7..f5e332a29 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2131,7 +2131,8 @@ works you probably want to add it to 
`org-agenda-custom-commands' for good."
 The inserted header depends on `org-agenda-overriding-header'.
 If the empty string, don't insert a header.  If any other string,
 insert it as a header.  If nil, insert DEFAULT, which should
-evaluate to a string."
+evaluate to a string.  If a function, call it and insert the
+string that it returns."
   (declare (debug (form)) (indent defun))
   `(cond
 ((not org-agenda-overriding-header) (insert ,default))
@@ -2140,6 +2141,8 @@ evaluate to a string."
  (insert (propertize org-agenda-overriding-header
 'face 'org-agenda-structure)
 "\n"))
+((functionp org-agenda-overriding-header)
+ (insert (funcall org-agenda-overriding-header)))
 (t (user-error "Invalid value for `org-agenda-overriding-header': %S"
   org-agenda-overriding-header
 
@@ -5046,10 +5049,11 @@ used by user-defined selections using 
`org-agenda-skip-function'.")
 (defvar org-agenda-overriding-header nil
   "When set during agenda, todo and tags searches it replaces the header.
 If an empty string, no header will be inserted.  If any other
-string, it will be inserted as a header.  If nil, a header will
-be generated automatically according to the command.  This
-variable should not be set directly, but custom commands can bind
-it in the options section.")
+string, it will be inserted as a header.  If a function, insert
+the string returned by the function as a header.  If nil, a
+header will be generated automatically according to the command.
+This variable should not be set directly, but custom commands can
+bind it in the options section.")
 
 (defun org-agenda-skip-entry-if ( conditions)
   "Skip entry if any of CONDITIONS is true.
-- 
2.31.1




[PATCH] org-agenda: Allow org-agenda-overriding-header to be a function

2021-08-12 Thread Christopher League
I thought this would be a nice extension to an existing customization
option for org-agenda. Commit message has an example and rationale.
Comments and amendments welcome, of course. I signed FSF copyright
assignment previously. Thanks, Chris





Re: [O] org-plus-contrib tar disappeared from orgmode.org/elpa/

2018-01-04 Thread Christopher League
Nicolas Goaziou  writes:

> I see all the versioned copies at the location you point out. Can you
> confirm they reappeared?

Ah yes, that's better... everything is back and the package builds fine
now.

> OOC, why
>
>   homepage = "https://elpa.gnu.org/packages/org.html;;
>
> instead of
>
>   homepage = "https://orgmode.org/;

That's a good point -- this is generated from a tool called `emacs2nix`
that converts any ELPA package into a nix specification. So that might
be from a template that assumes everything gets a homepage on
`elpa.gnu.org`. I'm not the maintainer, but I'll take a quick look to
see if it's easy to improve.

CL


[O] org-plus-contrib tar disappeared from orgmode.org/elpa/

2018-01-03 Thread Christopher League

Hi, this is a plea to retain versioned copies of the org-plus-contrib
tar in the  directory, because package
managers refer to them. Currently, the only versions present at that
location are 20171227 and 20171228.

I'm using NixOS, and my current nixpkgs tree refers to 20170911, which
cannot (re)-build now because the source is missing. Here's the Nix
specification referencing the now-broken URL:



The latest nixpkgs master does have it updated to 20171225 -- which is
*also* a broken link, just a week later. (And I prefer to use a 'stable'
channel rather than master.)



I don't necessarily expect orgmode.org to retain these sources
indefinitely, but deleting them after a couple of weeks or months causes
all sorts of headaches.

Thanks for the consideration!

CL


signature.asc
Description: PGP signature


[O] [PATCH] Fix message format in org-notmuch-search-open

2015-05-15 Thread Christopher League
* org-notmuch.el (org-notmuch-search-open): Bug fix
When opening a notmuch-search link, we use =message= to display the
path at the bottom of the screen.  This would signal Not enough
arguments for format string when the path contained %-signs, as it is
likely to when the query contains spaces:
[[notmuch-search:tag:inbox%2520not%2520tag:bulk%2520org]]

That query appears to be double-escaped, which also might contribute
to the problem, but either way: we should use =(message %s str)= to
print arbitrary strings, not =(message str)=.
---
 contrib/lisp/org-notmuch.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/lisp/org-notmuch.el b/contrib/lisp/org-notmuch.el
index ae9b50b..712ec5a 100644
--- a/contrib/lisp/org-notmuch.el
+++ b/contrib/lisp/org-notmuch.el
@@ -113,7 +113,7 @@ Can link to more than one message, if so all matching 
messages are shown.
 
 (defun org-notmuch-search-open (path)
   Follow a notmuch message link specified by PATH.
-  (message path)
+  (message %s path)
   (funcall org-notmuch-search-open-function path))
 
 (defun org-notmuch-search-follow-link (search)
-- 
2.4.0




[Orgmode] [PATCH] fix org-feed when retrieve-method is curl or wget

2009-06-30 Thread Christopher League
Hi Carsten and everyone. I love using org-feed, to gather various  
collection points (delicious, starred in google reader, dial2do, etc)  
into org-mode.


I tried switching the org-feed-retrieve-method to curl or wget, and  
encountered some bugs. The fixes were simple, and the full details are  
in the attached git patch.


The problem I was trying to solve, however, was that delicious.com  
would return a 500 server error sometimes with url.el, and I'm not  
sure why.  It returns RSS content anyway, with the error message as an  
item. Org-feed doesn't notice the HTTP response status, and  
processes the error as if it were a legit item (which means that next  
time the error occurs, it is silent).  Now that I got curl working,  
the 500 doesn't seem to happen anymore.


My hypotheses so far: maybe it has something to do with the user- 
agent, or with mangling special characters in the URL.  The delicious  
URL contains the '' argument separator, and when the error message  
comes back, it appears with something like 'amp;amp;' in it.. as if  
it were replaced twice.  I haven't traced further, to determine if  
fault lies with url.el or with delicious.com.


Best wishes
Chris



0001-fix-org-feed-when-retrieve-method-is-curl-or-wget.patch
Description: Binary data


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


[Orgmode] wish list: sort tasks by age

2009-06-30 Thread Christopher League
I would love to be able to sort TODOs by their age, so it becomes  
painfully obvious what I have been ignoring.  Since org relies on free- 
form text (a strength), it's tricky to ensure that every item gets a  
'creation-time' property.  But it doesn't need to be accurate to the  
second; even a script that added that property once every day or so  
might do the trick.


Since I commit my agenda files to git every day or so, I can actually  
get an approximation to this with git-blame... grep the TODO  
headlines, then sort by commit date.  It's pretty hackish, and I'm not  
sure I want to go to the trouble of integrating that raw data with the  
agenda view, if there's a better way within org.


Ideas? Thanks!
Chris



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


[Orgmode] org-attach git-commit limitations

2009-06-03 Thread Christopher League

Hi folks,

I started trying to use the org-attach feature (C-c C-a) and I like  
the idea that it can auto-commit attachment changes to a git repo. But  
I noticed some shortcomings...


1. I like to keep the entire org-directory under version control, but  
org-attach only commits if the org-attach-directory is the root of the  
repo. Instead of using (file-exists-p (expand-file-name .git dir))  
in org-attach-commit, why not just TRY the git add shell command in  
that dir and check the return value to see whether to continue with  
the commit?


2. I got the above working, but then I noticed that if you use the  
ATTACH_DIR property to redirect attachments elsewhere, org-attach- 
commit ignores that and still tries to synchronize the standard org- 
attach-directory.


Below I have a patch to address both of these, but I don't recommend  
applying it yet... if the ATTACH_DIR happens to be in a normal source  
tree, users may not want to auto-commit to it, particularly with such  
an unhelpful log message. So I'd like to add an ATTACH_DIR_COMMIT flag  
that, when set, indicates it's okay to auto-commit the ATTACH_DIR.


Other suggestions about how to customize whether or not to commit on a  
per-directory basis are welcome.. maybe a org-attach-commit-dirs  
variable that's a boolean, a list or a regex, combined with the  
ATTACH_DIR_COMMIT property..?


Thanks,
Chris

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 5f439da..a59b2ec 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -240,11 +240,12 @@ the ATTACH_DIR property) their own attachment  
directory.

 (defun org-attach-commit ()
   Commit changes to git if `org-attach-directory' is properly  
initialized.
 This checks for the existence of a \.git\ directory in that  
directory.

-  (let ((dir (expand-file-name org-attach-directory)))
-(if (file-exists-p (expand-file-name .git dir))
+  (let ((dir (org-attach-dir)))
+(if (and dir
+ (= 0 (shell-command
+   (concat (cd  dir ; git add .)
(shell-command
 (concat (cd  dir ; 
- git add .; 
  git ls-files --deleted -z | xargs -0 git rm; 
  git commit -m 'Synchronized attachments'))




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


Re: [Orgmode] processing pending emails as part of your GTD system

2008-04-23 Thread Christopher League

On Apr 23, 2008, at 11:34 AM, [EMAIL PROTECTED] wrote:
How did you know about this ``message://%3c%3e'' schema syntax!?  Is  
there anything else I can do to Mail from within Emacs (or from  
within Quicksilver {see footnote}).  Where can I read more! Is it  
safe to upgrade Mail (i.e. if I upgrade to OS X 10.666 will this  
script break?)


Things like this change all the time between OS revisions, so no  
guarantee.  I think the message URLs are new in Leopard (10.5).  You  
can find some details here:


http://daringfireball.net/2007/12/message_urls_leopard_mail

The macosxhints.com site is good too for tricks like that.  I think I  
just modified someone else's Copy Message URL script to put it in  
the right format for org-mode.  I'm no apple-script expert either.


It seems that the message is found even if I move it to another  
folder within Mail after generating the link; anything I need to be  
warned about?


Yes, Mail in Leopard indexes all the messages and (usually) follows  
them through refiles.  Once in a while a linked message can't be  
found, but if I revisit the folder or synchronize with server, then  
it works again.


I often have two message viewers open (one with mailboxes showing  
and one without, for easier filing {see footnote}) -- how does your  
script (or Mail) choose which one is 'selected'?


No idea, likely the last Mail window with focus?

1) Why doesn't the applescript work for the messages in the first  
folder I tried - my GTD folder?  Messages from the org-mode digest  
are automatically filed to On My Mac - Reference - GHI -  
GTD to help keep my inbox clean.  But any message I try to run  
your script on gives me blank id properties.


Example: [[message://%3c%3e][Emacs-orgmode Digest, Vol 26, Issue 54]]


Hm, that %3c%3e means that there was no message-ID field for that  
message.  If you look at Long Headers and there IS a Message-ID:  
field (there is on org-mode messages for me), then maybe it has to do  
with Mail's index after auto-filing.  I do my auto-filing on the  
server with procmail, so I never use Mail's facility for that.


2) The emacs-lisp code calls (yank) which doesn't grab text from the  
Apple Clipboard for me.  I am using GNU Emacs 22.1.50.1 (powerpc- 
apple-darwin7.9.0, Carbon Version 1.6.0) of 2007-10-02 on  
applecore.inf.ed.ac.uk - Aquamacs Distribution 1.2a and org-version  
5.23a.  Instead, I modified your code to use (cua-paste).


Okay, simple enough.  Mine is GNU Emacs 22.2.1 (i386-apple-darwin9,  
Carbon Version 1.6.0) [compiled from emacs22-carbon in Fink].


I use Quicksilver, but don't have much in the way of Mail  
integration.  Let me know if you find something.



Chris



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


Re: [Orgmode] processing pending emails as part of your GTD system

2008-04-22 Thread Christopher League

On Apr 21, 2008, at 2:55 AM, Pete Phillips wrote:
One thing I have done is design a method so that I can easily put  
emails
into a set of 'pending' mail folders, and then get cron to process  
these

and dump the emails back into my +inbox at appropriate dates.


Interesting, I have a similar script that also requires cron/shell  
access to mail server, but works with mbox format instead of MH, and  
is compatible with, e.g., dovecot IMAP server.  Mine is slightly less  
fancy, in that I file messages to absolute folders named days/25 or  
months/07-July (rather than nextweek) to have them dumped back  
into my spool at the indicated time.  See the 'email-tickler-update'  
script attached.



More relevant to org-mode, I have an emacs-lisp/apple-script combo for  
pasting links to Apple Mail messages into org files:


(defun cal-grab-mail-links ()
  (interactive)
  (call-process /usr/bin/osascript nil t nil
/home/league/Library/Scripts/Applications/Mail/Copy  
Message for OrgMode.scpt)

  (yank))
(define-key org-mode-map \C-cm 'cal-grab-mail-links)

; and the .scpt component:

-- Replace all occurences of one string for another in a text
-- The trick here is to change the internal delimiter,
-- spliting and joining the text
--
on replaceString(theText, oldString, newString)
set AppleScript's text item delimiters to oldString
set tempList to every text item of theText
set AppleScript's text item delimiters to newString
set theText to the tempList as string
set AppleScript's text item delimiters to 
return theText
end replaceString

tell application Mail
set _sel to get selection
set _links to {}
repeat with _msg in _sel
set _subj to _msg's subject
set _subj to my replaceString(_subj, [, ()
set _subj to my replaceString(_subj, ], ))
		set _messageURL to [[message://%3c  _msg's message id  %3e][   
_subj  ]]

set end of _links to _messageURL
end repeat
set AppleScript's text item delimiters to return
set the clipboard to (_links as string)
end tell

#!/usr/bin/env zsh
## email-tickler-update -- manage a set of 43 mailboxes as a 'tickler' file
## Written by and for Christopher League [EMAIL PROTECTED]
## but released to the public domain.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

   ### Settings ###

mail_spool=/var/mail
mail_dir=mail

today=$(date +%d)# 03, 14, 31, ...
month=$(date +%m-%b) # 02-Feb, 11-Nov, ...

day_mbox=${mail_dir}/days/${today}
month_mbox=${mail_dir}/months/${month}

users=($*)

   ### Helper functions ###

## Maybe run a command; maybe print it instead.  If this script is run
## with DRYRUN set (to anything except empty string), it will avoid
## taking any real actions, and just print the commands.
run() {
if [[ -z $DRYRUN ]]; then   # do it for real
$*
else# output only
print '%' $*
fi
}

## Run a command, but exit with message on error.
guard() {
run $*
if [[ $? != 0 ]]; then
print FATAL($?): $*
exit $?
fi
}

readable() {
if [[ ! -r $1 ]]; then
print unreadable: $1
exit 1
fi
}

   ### Primary actions ###

## Append given file to mail spool, then empty it out.
move_to_spool() {
cat $1 ${user_mail_spool}
print -n $1
}

## This wraps the above with the proper locking protocol, and does it
## only if given mailbox is non-empty.
protected_move() {
guard lockfile $1.lock
if [[ -s $1 ]]; then
guard lockfile ${user_mail_spool}.lock
guard move_to_spool $1
guard rm -f ${user_mail_spool}.lock
fi
guard rm -f $1.lock
}

  ### Main loop ###

for u in $users; do
user_mail_spool=${mail_spool}/$u
readable ${user_mail_spool}
readable ~$u/${day_mbox}
readable ~$u/${month_mbox}
protected_move ~$u/${day_mbox}
if [[ $today == 01 ]]; then
protected_move ~$u/${month_mbox}
fi
done

exit 0


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


Re: [Orgmode] RFC: interactive tag query adjustment

2008-01-12 Thread Christopher League





CAVEATS:

1. Carsten, my signed papers are on their way back to FSF; I'll let  
you know when I have a copy with their signature too.


2. Keys (even auto-assigned ones) can conflict between the tags and  
todo-keywords; in this case, the todo takes precedence.  This is  
disappointing if you have a key assigned to tag focus(f) and  
meanwhile have a #+TYP_TODO: Fred in some buffer.  Fred will get  
assigned the key f and make focus inaccessible.  Same thing  
happens with fast-tag-selection if include-todo is on, so it's not  
unique to my patch, and maybe needs a more general solution.


3. The main function `org-agenda-query-selection' started as a copy of  
`org-fast-tag-selection' and there are possibly some parts that could  
be reasonably factored out of both and shared.  (Mostly the code that  
lays out the tag names and keys in the buffer.)


4. ...? Let me know if you find anything else strange.


On Dec 8, 2007, at 9:00 AM, Christopher League wrote:
Hi, I've been using org-mode for about a year, and recently updated  
to the latest release.  I was happy to discover the enhanced tag  
query features (phone|email/NEXT|SOMEDAY, etc) and started  
rethinking my configuration a little.


I'd like to have an interface for interactive query adjustment.  For  
example, in a tags match (C-c a m, org-tags-view), I could begin  
with the query phone/NEXT and type the keys /h to quickly turn  
it into phone+home/NEXT and then ;s to get phone+home/NEXT| 
SOMEDAY, then =[ to clear all the tags to /NEXT|SOMEDAY, and so  
on.  Then, one more keystroke to save the current query into org- 
agenda-custom-commands would be icing on the cake.


I'm new to the mailing list, so maybe some functionality like this  
was discussed before.  Closest I found was a thread begun by John W  
in October, wherein interactive and query were mentioned  
together a few times... http://thread.gmane.org/gmane.emacs.orgmode/3628 
  but I don't think it's the same idea.




smime.p7s
Description: S/MIME cryptographic signature
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] RFC: interactive tag query adjustment

2007-12-08 Thread Christopher League


On Dec 8, 2007, at 1:29 PM, Adam Spiers wrote:

The idea sounds great! though I copied your code into a buffer, did
M-x eval-buffer, typed C-c a m and couldn't get any of the electric
keys to behave any differently to normal.  Not sure if I did something
wrong.


Huh, okay.  Maybe the code is rougher than I thought.  :)

The first step is, from the *Org Agenda* buffer, try C-h c / to make  
sure it is bound to cl-agenda-tag-and-cmd.  If not, then maybe the org- 
defkey failed.  Also, org-tag-alist must be set up with shortcut keys  
for each tag.  If this is the case, then typing /h should add  
+home to the current query, assuming you have (home . ?h) in org- 
tag-alist.  It will NOT prompt for anything after typing just the /.


I'll paste the rest of my current org config below, in case there's  
some other relevant assumption I'm making about how things are set  
up.  My org-version is 5.16a.  If this needs further troubleshooting,  
maybe we can take it off-list until it gets resolved.


Thanks,
Chris

;; current org configuration

(setq org-agenda-files ~/v/plan/orgfiles.txt)
(setq org-startup-folded nil)
(setq org-hide-leading-stars t)
(setq org-todo-keywords
  ;; task states
  '((type NEXT(N) | WAIT(W) DONE(D))
;; project states
(sequence | ONEDAY(O) ACTIVE(A) CLOSED(C
(setq org-todo-keyword-faces
  '((NEXT . (:foreground green3 :weight bold))
(WAIT . (:foreground orange2 :weight bold))
(DONE . (:foreground red4 :weight bold))
(ONEDAY . (:foreground orange2 :inverse-video t))
(ACTIVE . (:foreground green3 :inverse-video t))
(CLOSED . (:foreground red4 :inverse-video t
(setq org-fast-tag-selection-include-todo t)

(setq org-tag-alist
  '((ARCHIVE . ?-)
(:startgroup)
(focus . ?f)
(tired . ?t)
(:endgroup)
(:startgroup)
(inet . ?i)
(comp . ?c)
(:endgroup)
(:startgroup)
(email . ?m)
(phone . ?p)
(:endgroup)
(:startgroup)
(home . ?h)
(office . ?o)
(errand . ?e)
(:endgroup)))
(setq org-log-done nil)
(setq org-use-tag-inheritance nil)

(setq org-agenda-ndays 10)
(setq org-stuck-projects
  '(/ACTIVE (NEXT WAIT)
nil ))

(setq org-agenda-sorting-strategy
  '((agenda time-up priority-down category-keep)
(todo priority-down tag-up category-keep)
(tags priority-down tag-up category-keep)))



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