* searchable refcard
[not found] <E1L7WK3-0008Jz-45@box188.bluehost.com>
@ 2008-12-02 15:09 ` Robert Goldman
2008-12-02 20:47 ` Sebastian Rose
0 siblings, 1 reply; 2+ messages in thread
From: Robert Goldman @ 2008-12-02 15:09 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: searchable refcard
2008-12-02 15:09 ` searchable refcard Robert Goldman
@ 2008-12-02 20:47 ` Sebastian Rose
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Rose @ 2008-12-02 20:47 UTC (permalink / raw)
To: emacs-orgmode
Hi Robert,
those functions you mentioned are on my list for long winter nights :-)
Robert Goldman <rpgoldman@sift.info> writes:
> (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...
Sometimes more than just one section of the manual match the context. I
would like to choose in those situations. While on a checkbox item, the
sections `checkboxes' and 'plain lists' both match. RET RET should just
open the default (which would be the first of those two).
> 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.
Regards,
Sebastian
--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.: +49 (0)511 - 36 58 472
Fax: +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Email: s.rose emma-stil de, sebastian_rose gmx de
Http: www.emma-stil.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-02 20:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <E1L7WK3-0008Jz-45@box188.bluehost.com>
2008-12-02 15:09 ` searchable refcard Robert Goldman
2008-12-02 20:47 ` Sebastian Rose
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).