unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Using hash table to apply command sequence with arguments
@ 2024-11-25 12:05 Heime via Users list for the GNU Emacs text editor
  2024-12-22 12:42 ` Joel Reicher
  0 siblings, 1 reply; 3+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-25 12:05 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

How can use a hash table to execute a sequence of commands, 
possibly with arguments.  Here I am decoupling the action 
from the conditions.  Would this be a good strategy?

(defun fpln-test (actm-service)

  (let ((actm-table (make-hash-table :test 'eq)))

    ;; Put entry to actm-table
    (puthash 'armg (lambda ()
                     (alkotr-ar ar)
                     (alkotr-af af)))
              actm-table)

    ;; Put entry to actm-table
    (puthash 'go   (lambda ()
                     (require 'alkotr)
                     (alkotr-ignition gf))
             actm-table)

    ;; Map values from collection with lookup from hash table
    (mapc (lambda (actm)
            (let ((action (gethash actm actm-table)))
              (if action
                   (funcall action)
                (message "[marshal-falkotr]\n%s%s\n"
                         "  └── ACTM Unrecognised:" "'" actm))))
          actm-service)))



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-23  6:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-25 12:05 Using hash table to apply command sequence with arguments Heime via Users list for the GNU Emacs text editor
2024-12-22 12:42 ` Joel Reicher
2024-12-23  6:10   ` Jean Louis

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).