emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Search in descriptive plain lists
@ 2021-08-19 11:04 Juan Manuel Macías
  0 siblings, 0 replies; only message in thread
From: Juan Manuel Macías @ 2021-08-19 11:04 UTC (permalink / raw)
  To: orgmode

Hi all,

For my translation (work in progress) of Homer's Odyssey I am writing a long descriptive
plain list which is a glossary of Homeric formulas (in Homer a 'formula' is a passage that
is repeated exactly the same, or with slight variations, throughout the work: a very
typical resource of traditional poems). This glossary helps me remember how I have
translated a certain formula before. But it was a bit awkward for me having to query the
list every time so I wrote a function which returns as a message the item searched after
writing or marking a few words. I have redone a bit the code to give it a more general
use, and I share it here, in case someone found useful or perhaps would like to improve
it. The idea is to search in descriptive lists within sections containing the tag :makealist:
(one list per section). And has more sense when the descriptive lists work as a kind of
glossary.

#+begin_src emacs-lisp
  (setq my-org/desc-plainlist-alist nil)
  
  (defun my-org/search-desc-plainlist ()
    (interactive)
    (org-map-entries
     (lambda ()
       (save-restriction
	 (org-narrow-to-subtree)
	 (when
	     (re-search-forward "^- " nil t)
	   (beginning-of-line)
	   (mapc (lambda (el)
		   (add-to-list 'my-org/desc-plainlist-alist el))
		 (cdr (org-list-to-lisp))))))
     "makealist")
    (let ((element-re (if (region-active-p)
			  (buffer-substring-no-properties (region-beginning) (region-end))
			(read-from-minibuffer "Search in descriptive lists: "))))
      (setq my-org/desc-plainlist-candidate
	    (assoc-if
	     (lambda (x)
	       (string-match-p element-re x))
	     my-org/desc-plainlist-alist))
      (message
       (mapconcat 'identity
		  my-org/desc-plainlist-candidate ""))))
#+end_src

Best regards,

Juan Manuel 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-19 11:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 11:04 Search in descriptive plain lists Juan Manuel Macías

Code repositories for project(s) associated with this 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).