[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Search in descriptive plain lists

From: Juan Manuel Macías
Subject: Search in descriptive plain lists
Date: Thu, 19 Aug 2021 11:04:01 +0000

Hi all,

For my translation (work in progress) of Homer's Odyssey I am writing a long 
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 
typical resource of traditional poems). This glossary helps me remember how I 
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 
use, and I share it here, in case someone found useful or perhaps would like to 
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

#+begin_src emacs-lisp
  (setq my-org/desc-plainlist-alist nil)
  (defun my-org/search-desc-plainlist ()
     (lambda ()
             (re-search-forward "^- " nil t)
           (mapc (lambda (el)
                   (add-to-list 'my-org/desc-plainlist-alist el))
                 (cdr (org-list-to-lisp))))))
    (let ((element-re (if (region-active-p)
                          (buffer-substring-no-properties (region-beginning) 
                        (read-from-minibuffer "Search in descriptive lists: 
      (setq my-org/desc-plainlist-candidate
             (lambda (x)
               (string-match-p element-re x))
       (mapconcat 'identity
                  my-org/desc-plainlist-candidate ""))))

Best regards,

Juan Manuel 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]