Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Programming is an unnatural act.


computers / gnu.emacs.help / Re: which-func-mode in derived mode

SubjectAuthor
o Re: which-func-mode in derived modeAxel Reichert

1
Re: which-func-mode in derived mode

<87jzw4j6nk.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=1&group=gnu.emacs.help#1

  copy link   Newsgroups: gnu.emacs.help
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: gnu.emacs.help
Subject: Re: which-func-mode in derived mode
Date: Fri, 16 Jun 2023 07:52:15 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <87jzw4j6nk.fsf@axel-reichert.de>
References: <87pm653ntz.fsf@axel-reichert.de>
<004jnhqakk.fsf@pc-lheea204.ec-nantes.fr>
<87h6rgodni.fsf@axel-reichert.de>
<00zg54u9xc.fsf@pc-lheea204.ec-nantes.fr>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="48da14afc668a656cd9a12528db14466";
logging-data="801234"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194FkwKM1ByKly0bCxi/AaHzydnamPRzLY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:+CeF17zKwmUUa2CqPlFoTln5ndI=
sha1:Pro0yTR3v6bHXhubQDN31p9I9F4=
 by: Axel Reichert - Fri, 16 Jun 2023 05:52 UTC

Thomas Dupond <thomas@dupond.eu> writes:

> I delved a little bit deeper and apparently you should be able to do
> what you want after you have defined the variable
> imenu-generic-expression or the variable imenu-create-index-function.
> Fortran mode uses the former and Org mode the latter (respectively in
> fortran-mode.el and org-compat.el).

Many thanks for your research! It works now:

(add-to-list 'auto-mode-alist '("\\.mini2\\'" . mini2-mode))

(defun mini2-mode-which-func ()
"XXX")

(add-hook 'which-func-functions #'mini2-mode-which-func)

(define-derived-mode mini2-mode
text-mode "Mini2"
"Major mode for editing .mini2 files."
(which-function-mode 1)
(defvar mini2-imenu-generic-expression
(list
(list
nil
"^\*\\ \\(.*\\)$"
1)
(list
nil
"^\*\*\\ \\(.*\\)$"
1)))
(set (make-local-variable 'imenu-generic-expression)
mini2-imenu-generic-expression))

(provide 'mini2)

correctly shows "XXX" in the mode line after

emacs -Q -l mini2-mode.el foo.mini2

Thanks again and best regards

Axel (not Alex)


computers / gnu.emacs.help / Re: which-func-mode in derived mode

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor