all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* function with multiple symbol instructions
@ 2024-08-27 13:16 Heime
  2024-08-27 13:34 ` uzibalqa
  0 siblings, 1 reply; 2+ messages in thread
From: Heime @ 2024-08-27 13:16 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I want a function to have the capability of passing multiple
symbol instructions in its argument.  I am using mapc to parse
the symbols.  Is this a good way as implementation goes ?


(defun marsot (&optional actn-list)
  "Add marsot path and requirements."

  ;; Check each symbol in actm-list
  (mapc (lambda (actn)
          (cond ( (eq actn 'armg)
	            (add-to-list 'load-path "~/Opstk/bin/marsot"))

                ( (eq actn 'go)
	            (require 'marsot)
	            (marsot-start))

	        (t  (message "Unknown ACTN value: %s" actn))))
	actn-list)))





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

* Re: function with multiple symbol instructions
  2024-08-27 13:16 function with multiple symbol instructions Heime
@ 2024-08-27 13:34 ` uzibalqa
  0 siblings, 0 replies; 2+ messages in thread
From: uzibalqa @ 2024-08-27 13:34 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor


On Wednesday, August 28th, 2024 at 1:16 AM, Heime <heimeborgia@protonmail.com> wrote:

> I want a function to have the capability of passing multiple
> symbol instructions in its argument. I am using mapc to parse
> the symbols. Is this a good way as implementation goes ?

Perhaps using pcase would be capable for more advanced pattern matching,
am I right ? 

  (dolist (actn actn-list)
    (pcase actn
      ('armg  (add-to-list 'load-path "~/Opstk/bin/marsot"))
      ('go    (require 'marsot)
              (marsot-start))
      (_ (message "Unknown actn value: %s" actn)))))
 
Mapping directly over the list of actions and call the corresponding functions
should be useful when the action functions do not require any conditions or 
additional logic. 
 
> (defun marsot (&optional actn-list)
> "Add marsot path and requirements."
> 
> ;; Check each symbol in actm-list
> (mapc (lambda (actn)
> (cond ( (eq actn 'armg)
> (add-to-list 'load-path "~/Opstk/bin/marsot"))
> 
> ( (eq actn 'go)
> (require 'marsot)
> (marsot-start))
> 
> (t (message "Unknown ACTN value: %s" actn))))
> actn-list)))
>



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

end of thread, other threads:[~2024-08-27 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27 13:16 function with multiple symbol instructions Heime
2024-08-27 13:34 ` uzibalqa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.