unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* defalias inside a defun
@ 2024-04-06  0:59 Heime
  2024-04-09  9:43 ` Joost Kremers
  0 siblings, 1 reply; 4+ messages in thread
From: Heime @ 2024-04-06  0:59 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Would it be acceptable to call a defalias inside a defun ?\

I have the function avus and want to make a few alias functions 
when requiring a specific file.  For instance including gala-bash-func
as an alternative to avus-bash-func defined in avus-bash.el

(defun gala ()
  "Require libraries based on major mode."
  (interactive)

  (cond

    ((eq major-mode 'sh-mode)
          (require 'avus-bash)
          (defalias 'gala-bash-func #'avus-bash-func))))





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

* Re: defalias inside a defun
  2024-04-06  0:59 defalias inside a defun Heime
@ 2024-04-09  9:43 ` Joost Kremers
  2024-04-09 12:13   ` Heime
  0 siblings, 1 reply; 4+ messages in thread
From: Joost Kremers @ 2024-04-09  9:43 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

On Sat, Apr 06 2024, Heime wrote:
> Would it be acceptable to call a defalias inside a defun ?\

"Acceptable" how? Stylistically? Technically?

Technically, I don't think it matters whether defalias occurs at the top level
or inside a defun.

Stylistically, I don't really see anything wrong with it, but there's no
accounting for taste. :-)


-- 
Joost Kremers
Life has its moments



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

* Re: defalias inside a defun
  2024-04-09  9:43 ` Joost Kremers
@ 2024-04-09 12:13   ` Heime
  2024-04-09 13:48     ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Heime @ 2024-04-09 12:13 UTC (permalink / raw)
  To: Joost Kremers; +Cc: Heime via Users list for the GNU Emacs text editor


On Tuesday, April 9th, 2024 at 9:43 PM, Joost Kremers <joostkremers@fastmail.fm> wrote:

> On Sat, Apr 06 2024, Heime wrote:
> 
> > Would it be acceptable to call a defalias inside a defun ?\
> 
> 
> "Acceptable" how? Stylistically? Technically?

Technically.  I want to make available some aliases dependent upon certain
modes. 

(defun gali-exigens (seltr)
  "Load requirements based upon specific major modes and define
`gali' commands to access `avus' functionalities using
alternative names via aliases."

  (pcase seltr
    ;;------------------------------------------------------------
    ("Bash"
       (require 'avus-bash)
       (defalias 'gali-bash-zilindr #'avus-bash-zilindr
         "Insert bash constructs."))
    ;;------------------------------------------------------------
    ("Latex"
       (require 'avus-latex)
       (defalias 'gali-latex-zilindr #'avus-latex-zilindr
         "Insert latex constructs.")
       (defalias 'gali-latex-vjero #'avus-latex-vjero
         "Insert latex probability constructs.")
       (defalias 'gali-latex-ams #'avus-latex-ams
         "Insert latex ams constructs.")
       (defalias 'gali-latex-stix #'avus-latex-stix
         "Insert latex stix constructs.")) )

 
> Technically, I don't think it matters whether defalias occurs at the top level
> or inside a defun.
> 
> Stylistically, I don't really see anything wrong with it, but there's no
> accounting for taste. :-)
> 
> --
> Joost Kremers
> Life has its moments




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

* Re: defalias inside a defun
  2024-04-09 12:13   ` Heime
@ 2024-04-09 13:48     ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-04-09 13:48 UTC (permalink / raw)
  To: help-gnu-emacs

>   (pcase seltr
>     ;;------------------------------------------------------------
>     ("Bash"
>        (require 'avus-bash)
>        (defalias 'gali-bash-zilindr #'avus-bash-zilindr
>          "Insert bash constructs."))
>     ;;------------------------------------------------------------
>     ("Latex"
>        (require 'avus-latex)
>        (defalias 'gali-latex-zilindr #'avus-latex-zilindr
>          "Insert latex constructs.")
>        (defalias 'gali-latex-vjero #'avus-latex-vjero
>          "Insert latex probability constructs.")
>        (defalias 'gali-latex-ams #'avus-latex-ams
>          "Insert latex ams constructs.")
>        (defalias 'gali-latex-stix #'avus-latex-stix
>          "Insert latex stix constructs.")) )

I don't know what's your underlying intention, but I'll point out that
Emacs can be visiting both a Bash file and a LaTeX file at the very
same time.


        Stefan




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

end of thread, other threads:[~2024-04-09 13:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-06  0:59 defalias inside a defun Heime
2024-04-09  9:43 ` Joost Kremers
2024-04-09 12:13   ` Heime
2024-04-09 13:48     ` Stefan Monnier via Users list for the GNU Emacs text editor

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