[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] searchable refcard
From: |
Robert Goldman |
Subject: |
[Orgmode] searchable refcard |
Date: |
Tue, 02 Dec 2008 09:09:28 -0600 |
User-agent: |
Thunderbird 2.0.0.18 (Macintosh/20081105) |
I tried it the stupid way, just to see it working:
(defun org-context-help ()
"Context help for org-mode"
(interactive)
(if (org-at-table-p)
(info "(org)tables")
(if (org-at-timestamp-p)
(info "(org)timestamps")
(if (org-at-item-checkbox-p)
(info "(org)Checkboxes")
(if (org-at-item-p)
(info "(org)plain lists")
(if (org-at-heading-p)
(info "(org)headlines")
(if (org-at-property-p)
(info "(org)Properties and Columns")
)))))))
For this kind of multi-way branch, cond is easier to deal with:
(cond ((org-at-table-p)
(info "(org)tables"))
((org-at-timestamp-p)
(info "(org)timestamps"))
((org-at-item-checkbox-p)
(info "(org)Checkboxes"))
((org-at-item-p)
(info "(org)plain lists"))
((org-at-heading-p)
(info "(org)headlines"))
((org-at-property-p)
(info "(org)Properties and Columns")))
Just for the fun of it.
I tried to use a list like this:
(setq org-context-help-map
'(('org-at-item-checkbox-p "(org)Checkboxes" "(org)plain lists")
('org-at-item-p "(org)plain lists" "(org)Checkboxes")
('org-at-property-p "(org)Properties and Columns")
('org-at-timestamp-p "(org)timestamps" "(org)deadlines and
scheduling")
('org-at-table-p "(org)tables")
('org-at-heading-p "(org)headlines")))
For this you need (require 'cl), but what about
(let ((cell (find-if (lambda (lst) (eval `(,(first lst))))
org-context-help-map)))
(when cell
(eval `(,(second cell)))))
The find avoids the need to do a non-local exit.
Note that I don't understand what you're doing with having two info
indices, so I ignored the second one...
Alternatively
(loop for (test info-entry info-entry2) in org-context-help-map
when (eval `(,test))
return info-entry)
using the loop macro...
BTW, I don't think you want that quote inside your definition of
org-context-help-map. You want '((org-at-item-checkbox-p ...)) not
'(('org-at-item-checkbox-p ...)) The extra quote will be a nuisance.
HTH,
R
- [Orgmode] searchable refcard,
Robert Goldman <=