From: Robert Goldman <rpgoldman@sift.info>
To: emacs-orgmode@gnu.org
Subject: searchable refcard
Date: Tue, 02 Dec 2008 09:09:28 -0600 [thread overview]
Message-ID: <49354FA8.8080106@sift.info> (raw)
In-Reply-To: <E1L7WK3-0008Jz-45@box188.bluehost.com>
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
next parent reply other threads:[~2008-12-02 15:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1L7WK3-0008Jz-45@box188.bluehost.com>
2008-12-02 15:09 ` Robert Goldman [this message]
2008-12-02 20:47 ` searchable refcard Sebastian Rose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49354FA8.8080106@sift.info \
--to=rpgoldman@sift.info \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).