all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Functions which are mode dependent
@ 2024-08-18 21:14 Heime
  2024-08-20 21:49 ` Heime
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Heime @ 2024-08-18 21:14 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I need some help understanding how to automatically enable some functionality
when loading a file with some major mode.

For instance I have a function that sets 


(defun expr-elisp ()

  (setq imenu-generic-expression
    `( ("defun" ,(concat "^\\s-*"
                   "(\\(defun\\|define-minor-mode\\)\\s-+"
                   "\\(\\(\\sw\\|\\s_\\)+\\)") 2) )) )


(defun expr-selector ()

  (cond
    ((eq major-mode 'emacs-lisp-mode)  (expr-elisp))
    (t  (expr-generic)) ))

I have put the code above in a minor mode. 

;;;###autoload
(define-minor-mode tema-minor-mode

  (if tema-minor-mode
        (expr-selector)
      (message "Tema Deactivated")))

with hooks to load the minor mode automatically for specific major modes.

(add-hook emacs-lisp-mode-hook #'tema-minor-mode)





^ permalink raw reply	[flat|nested] 16+ messages in thread
[parent not found: <cZeTZGgEO8ZqskRdwTYwyC8I8Nbdvc559IWYt1uERmxLYkgONsnVPIUsdZWEE43YjvR97Osjq3ZFn72HYANJnd0uZM10K1BZlgM-2iUDyAI=3D@protonmail.com>]

end of thread, other threads:[~2024-08-26 22:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-18 21:14 Functions which are mode dependent Heime
2024-08-20 21:49 ` Heime
2024-08-22 13:26   ` Heime
2024-08-23 10:05   ` Joel Reicher
2024-08-23 12:26     ` Heime
2024-08-22 18:29 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-08-22 18:42   ` Heime
2024-08-22 18:58 ` Yuri Khan
2024-08-22 22:07   ` Heime
2024-08-22 22:16     ` Heime
2024-08-22 23:38       ` Heime
2024-08-24  9:46         ` Heime
2024-08-24 10:20           ` Yuri Khan
2024-08-24 11:33             ` Heime
2024-08-24 21:08               ` Heime
2024-08-26 22:35                 ` Heime
     [not found] <cZeTZGgEO8ZqskRdwTYwyC8I8Nbdvc559IWYt1uERmxLYkgONsnVPIUsdZWEE43YjvR97Osjq3ZFn72HYANJnd0uZM10K1BZlgM-2iUDyAI=3D@protonmail.com>
     [not found] ` <CAP=5Fd=5F8XY-OK4kGu9LigEqbKiQgGft3ShWY58mrUPwqPcn15VPQ@mail.gmail.com>
     [not found]   ` <3RfPnnmfz0Qgr0JGJbNKnydaMu1QfnGGBk7xX7qxkXSkzXBNt8snc9Ye1n6AvZtOln0VoPDXmjnYc=5FX5lGkPVxnvPPlBbjvnuKMQs4cki18=3D@protonmail.com>
     [not found]     ` <qAaQUpb=5FJAFuU-wWLUZIi9mi6FRdXycVjQbRTi7ntswqlXGkv1k=5FaIwP9lr0av3lZ15ls2QpARUIkXOVwhHrlJ4wfyNv9PfiHjuVVzTANvc=3D@protonmail.com>
     [not found]       ` <b3r6FxVdJog97l0Sg4GtNPjvqS0kLsrpkgPKr8zOQnU3yNSLFkyCXgnGcrSaAT6hYmjme8qhUm3ecdhut8r6DXd4Hg=5FjRH0cU19tfjx=5F9JI=3D@protonmail.com>
     [not found]         ` <Y7NJnzV2gxP2ItkZNRVxRX8eD0Y-uEnE2EXo07CPNuckyabsLJoKMkpD82ReWhb3tFdL6uCFSsaLBhfZX7yXihd=5FNlUCgc2oBCFBbiv=5FCAw=3D@protonmail.com>
     [not found]           ` <CAP=5Fd=5F8UR+=3DB1GAKOTLwjgM=5FQ=5FGRbQttrwtO4 PD7wx9sJFErpcQ@mail.gmail.com>
     [not found]             ` <uumSbkMJHz2MJY2Yok3T3XDtIY2hSd8f=5FAYXIAqCmJYiv5Lf3in4c22uy6658I8RnsI4iIF-XWzGlfSPdX=5F13c6k1VPGPXov0Nnzeplp8e0=3D@protonmail.com>

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.