all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* imenu question (or an alternative)
@ 2014-05-13 20:52 Doug Lewan
  2014-05-13 21:58 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Lewan @ 2014-05-13 20:52 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

I've written a small mode for editing files containing lists of certain formats. I use which-function-mode (i.e. imenu) to index the lists.

Such lists might have a "preferred" entry depending on what directory it's in. The mode starts by putting the point on the "preferred" entry. This is nice, but then the imenu index starts only at that entry which makes the whole which-function/imenu combination less useful than it might be.

Here's the mode's current definition with the go-to-issue code at the very end. FYI without those two lines, the Issues menu gets populated correctly.

(define-derived-mode issues-mode text-mode "issues"
  "Major mode for files that might contain issues."
  :keymap 'issues-mode-map
  (make-local-variable 'beginning-of-defun-function)
  (make-local-variable 'end-of-defun-function)
  (setq beginning-of-defun-function 'iss-beginning-of-issue)
  (setq end-of-defun-function 'iss-end-of-issue)
  (setq imenu-create-index-function 'iss-mode-create-index)
  (setq imenu-sort-function 'imenu--sort-by-position)
  (unless which-function-mode
    (require 'which-func)
    (which-function-mode))
  (imenu-add-to-menubar "Issues")

  (let ((issue (iss-get-issue-for-directory)))
    (imenu issue)))

Is there a magic incantation that I don't know to make this do the right thing? (Is there an appropriate alternative to which-function/imenu?

Thanks.

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

LISP: The most intelligent way to misuse a computer.





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

* RE: imenu question (or an alternative)
  2014-05-13 20:52 imenu question (or an alternative) Doug Lewan
@ 2014-05-13 21:58 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2014-05-13 21:58 UTC (permalink / raw)
  To: Doug Lewan, help-gnu-emacs

> The mode starts by putting the point on the "preferred" entry. This is
> nice, but then the imenu index starts only at that entry which makes the
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> whole which-function/imenu combination less useful than it might be.
> 
> Here's the mode's current definition with the go-to-issue code at the very
> end. FYI without those two lines, the Issues menu gets populated correctly.
> 
> (define-derived-mode issues-mode text-mode "issues"
>   "Major mode for files that might contain issues."
>   :keymap 'issues-mode-map
>   (make-local-variable 'beginning-of-defun-function)
>   (make-local-variable 'end-of-defun-function)
>   (setq beginning-of-defun-function 'iss-beginning-of-issue)
>   (setq end-of-defun-function 'iss-end-of-issue)
>   (setq imenu-create-index-function 'iss-mode-create-index)
>   (setq imenu-sort-function 'imenu--sort-by-position)
>   (unless which-function-mode
>     (require 'which-func)
>     (which-function-mode))
>   (imenu-add-to-menubar "Issues")
> 
>   (let ((issue (iss-get-issue-for-directory)))
>     (imenu issue)))
> 
> Is there a magic incantation that I don't know to make this do the right
> thing? (Is there an appropriate alternative to which-function/imenu?

FWIW, I don't quite follow you.  `(imenu ISSUE)' should just go to the
position specified by ISSUE.  In particular, it should not change what
is in the `Issues' menu.

What do you mean by "then the imenu index starts only at that entry"?
And by menu `Issues' not getting populated correctly?  Calling `imenu'
should not have any bearing on what gets populated to menu `Issues',
which is done by `imenu-add-to-menubar'.

Without really understanding your problem, I'd suggest using
`M-x debug-on-entry imenu-add-to-menubar', to see why `Issues' is
not being populated with what you think it should be.

Or if you think that it is the call to `imenu' that somehow screws
up the menu, then trace that through the debugger, to see just what
it is doing.



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

end of thread, other threads:[~2014-05-13 21:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-13 20:52 imenu question (or an alternative) Doug Lewan
2014-05-13 21:58 ` Drew Adams

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.