[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] RFC: interactive tag query adjustment

2007-12-08 Thread Christopher League


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.



Below is a first crack at this kind of functionality.  It's very  
rough.. I've hacked elisp before, but I'm new to the org.el code.   
Load this after org, then "C-c a m", enter any match query, then try  
some of the commands with your tag shortcut keys.  It assumes you have  
some settings in org-tag-alist.  Currently, todo shortcut keys may not  
work because org-todo-key-alist is still nil; it's not clear to me how  
this should get initialized from agenda-mode.


Let me know what you think!  Thanks Carsten and community for all the  
hard work and great ideas surrounding org-mode!


Chris


;; Currently, it seems the query string is kept only as part of the
;; org-agenda-redo-command, which is a Lisp form.  A distinct global
;; would be cleaner, but that entails modifications to org-mode."
;; org-agenda-redo-command: (org-tags-view 'nil (if current-prefix-arg  
nil ""))

;;  The "" will contain the current query string
(defun cl-agenda-twiddle-query ()
  (cl-agenda-twiddle-iter org-agenda-redo-command))

(defun cl-agenda-twiddle-iter (sexp)
  "Find query string in SEXP and replace it."
  (if (consp sexp)
  (if (and (stringp (car sexp)) (null (cdr sexp)))
  (setcar sexp (cl-agenda-apply-changes (car sexp)))
(cl-agenda-twiddle-iter (car sexp))
(cl-agenda-twiddle-iter (cdr sexp)

(defun cl-agenda-apply-changes (str)
  (cl-agenda-apply-iter cl-agenda-op str cl-agenda-args))

(defun cl-agenda-apply-iter (op str args)
  (if (null args) str
(funcall op (cl-agenda-apply-iter op str (cdr args))
 (caar args) (cdar args

(defun cl-agenda-tag-clear (query kind str)
  (if (string-match (concat "[-\\+&|]?\\b" (regexp-quote str) "\\b")
query)
  (replace-match "" t t query)
query))

(defun cl-agenda-tag-set (query kind str)
  (let* ((q (cl-agenda-tag-clear query kind str))
 (r (string-match "\\([^/]*\\)/?\\(.*\\)" q))
 (q1 (match-string 1 q))
 (q2 (match-string 2 q)))
(cond
 ((eq kind 'tag)
  (concat q1 cl-agenda-sep str "/" q2))
 ((equal cl-agenda-sep "+")
  (concat q1 "/+" str))
 (t
  (concat q1 "/" q2 cl-agenda-sep str)

;;; ALMOST THERE: IT'S JUST THAT org-todo-key-alist IS NIL.

(defun cl-agenda-all (kind alist)
  (cond
   ((null alist) nil)
   ((stringp (caar alist))
(cons (cons kind (caar alist)) (cl-agenda-all kind (cdr alist
   (t
(cl-agenda-all kind (cdr alist)

(defun cl-agenda-interp-key (k)
  (let ((v1 (rassoc k org-tag-alist))
(v2 (rassoc k org-todo-key-alist)))
(cond
 ((eq k ? ) (append (cl-agenda-all 'tag org-tag-alist)
(cl-agenda-all 'todo org-todo-key-alist)))
 ((eq k ?[) (cl-agenda-all 'tag org-tag-alist))
 ((eq k ?]) (cl-agenda-all 'todo org-todo-key-alist))
 (v1 (list (cons 'tag (car v1
 (v2 (list (cons 'todo (car v2
 (t nil

(defun cl-agenda-tag-cmd (op sep)
  (let ((cl-agenda-op op)
(cl-agenda-sep sep)
(cl-agenda-args (cl-agenda-interp-key (read-char
(cl-agenda-twiddle-query))
  (org-agenda-redo))

(defun cl-agenda-tag-clear-cmd ()
  (interactive)
  (cl-agenda-tag-cmd 'cl-agenda-tag-clear ""))

(defun cl-agenda-tag-and-cmd ()
  (interactive)
  (cl-agenda-tag-cmd 'cl-agenda-tag-set "+"))

(defun cl-agenda-tag-or-cmd ()
  (interactive)
  (cl-agenda-tag-cmd 'cl-agenda-tag-set "|"))

(defun cl-agenda-tag-not-cmd ()
  (interactive)
  (cl-agenda-tag-cmd 'cl-agenda-tag-set "-"))

(org-defkey org-agenda-mode-map "=" 'cl-agenda-tag-clear-cmd)
(org-defkey org-agenda-mode-map "/" 'cl-agenda-tag-and-cmd)
(org-defkey org-agenda-mode-map ";" 'cl-agenda-tag-or-cmd)
(org-defkey org-agenda-mode-map "\\" 'cl-agenda-tag-not-cmd)



___
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


Re: [Orgmode] RFC: interactive tag query adjustment

2008-01-12 Thread Christopher League
ITION 2")
+  (setq alist (cons (cons (car entry) nil) alist)))
+ ;; else, prepend COPY of entry
+ (t
+  (setq alist (cons (cons (car entry) (cdr entry)) alist)
+  alist)
+
+(defun org-agenda-query-generic-cmd (op)
+  "Activate query manipulation with OP as initial operator."
+  (let ((q (org-agenda-query-selection org-agenda-query-string op
+   org-tag-alist 
+   (org-agenda-query-global-todo-keys
+(when q
+  (setq org-agenda-query-string q)
+  (org-agenda-redo
+
+(defun org-agenda-query-clear-cmd ()
+  "Activate query manipulation, to clear a tag from the string."
+  (interactive)
+  (org-agenda-query-generic-cmd "="))
+
+(defun org-agenda-query-and-cmd ()
+  "Activate query manipulation, initially using the AND (+) operator."
+  (interactive)
+  (org-agenda-query-generic-cmd "+"))
+
+(defun org-agenda-query-or-cmd ()
+  "Activate query manipulation, initially using the OR (|) operator."
+  (interactive)
+  (org-agenda-query-generic-cmd "|"))
+
+(defun org-agenda-query-not-cmd ()
+  "Activate query manipulation, initially using the NOT (-) operator."
+  (interactive)
+  (org-agenda-query-generic-cmd "-"))
+
 ;;; Agenda Finding stuck projects
 
 (defvar org-agenda-skip-regexp nil





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] 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] 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


[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





[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 (&rest conditions)
   "Skip entry if any of CONDITIONS is true.
-- 
2.31.1




[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


[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  
. 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 '&' 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


Re: [Orgmode] wish list: sort tasks by age

2009-07-01 Thread Christopher League
Thanks everyone. I think I managed to get something like David's  
suggestion working... I spent the most time trying to initialize the  
creation times from git though, with vc-annotate.. I don't think that  
was meant to be used non-interactively, but I beat it into shape. :)   
The other end of it is the agenda view, so I made a comparison  
function that puts them in order oldest to youngest. I made a gist for  
the snippet here: http://gist.github.com/138770 and I'll also paste  
below.


org-expiry is interesting.. I didn't know about that. Certainly  
there's a similarity, although the point of view is different: "tasks  
that are old and should be archived" vs. "tasks that are old and  
should be FINISHED!!!" :)  I haven't thought too much yet about how to  
unify the two ideas...


Chris

On Jul 1, 2009, at 7:58 AM, Bastien wrote:

David Maus  writes:
And what a fun it is to train my elisp skills. A first hack that  
seems to work:


(defun dmj/org-assure-creation-property ()
 "Process all orgmode entries of current buffer that do not
 match a defined search string"
 (interactive)
 (org-map-entries 'dmj/org-insert-creation-property "+Creation_Time= 
\"\"")

)

(defun dmj/org-insert-creation-property ()
 "Insert Creation-Property in Orgmode entry at point"
 (let ((stamp (format-time-string (cdr org-time-stamp-formats)  
(current-time

   (setq stamp (concat "[" (substring stamp 1 -1) "]"))
   (org-entry-put (point-marker) "Creation_Time" stamp))
)


Thanks for this David -- you might also have a look at the code in
org-expiry.el.  If there is anything there that you want to improve,
please do so!



;;; sorting org-mode tasks by age

(defconst org-age-property "CREATED")

(defun org-age-set-to-today-if-missing ()
  (interactive)
  (or (org-entry-get (point) org-age-property)
  (let ((d (format-time-string "%Y-%m-%d" (current-time
(org-entry-put (point) org-age-property d)
d)))

(defconst org-date-regexp "\\b[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\ 
\b")


(defun org-age-set-from-vc-if-missing ()
  (interactive)
  (or (org-entry-get (point) org-age-property)
  (let ((current-line (count-lines (point-min) (point)))
date-string)
(save-window-excursion
  (vc-annotate buffer-file-name (vc-workfile-version buffer- 
file-name))

  (if (search-forward-regexp org-date-regexp
 (point-at-eol) t)
  (setq date-string (match-string 0)))
  (kill-buffer nil)) ;; otherwise next annotation may be wrong
(when date-string
  (org-entry-put (point) org-age-property date-string)
  (basic-save-buffer)) ;; otherwise next annotation may be  
wrong

date-string)))

(defvar org-age-todo-match "/TODO|PROJECT|MAYBE|WAIT")

(defun org-age-set-all (setf)
  (let ((rs (org-map-entries setf org-age-todo-match 'agenda)))
rs))

(defun org-age-set-all-to-today ()
  (interactive)
  (org-age-set-all 'org-age-set-to-today-if-missing))
(org-age-set-all-to-today)

(defun org-age-set-all-from-vc ()
  (interactive)
  (org-age-set-all 'org-age-set-from-vc-if-missing))

(defun org-age-compare (a b)
  (let* ((ma (get-text-property 1 'org-marker a))
 (mb (get-text-property 1 'org-marker b))
 (da (with-current-buffer (marker-buffer ma)
   (goto-char (marker-position ma))
   (org-age-set-to-today-if-missing)))
 (db (with-current-buffer (marker-buffer mb)
   (goto-char (marker-position mb))
   (org-age-set-to-today-if-missing
(cond
 ((string< da db) -1)
 ((string= da db) nil)
 (t +1

(setq org-agenda-cmp-user-defined 'org-age-compare)

(setq org-agenda-custom-commands
  '(("z" "description"
 todo "TODO"
 ((org-agenda-sorting-strategy '(user-defined-up))
  (org-agenda-archives-mode nil)



___
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


[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


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