0

How can we rename Emacs "Imenu" into "Outline"?

The goal is NOT to break anything else, things which depend on Imenu, such as helm-imenu or helm-semantic-or-imenu.

user3341592
  • 1,419
  • 1
  • 17
  • 36
  • Please describe exactly where you see the word Imenu that you want to change to say Outline instead. A screenshot would be very helpful. – lawlist Jun 21 '16 at 15:50
  • I'd like the occurrence from the toolbar to be renamed. – user3341592 Jun 21 '16 at 16:09
  • The function `imenu-add-menubar-index` adds the word "Index" to the menu-bar, not "Imenu". A picture of what you want to change sure would be helpful. – lawlist Jun 21 '16 at 16:16
  • Thanks to your tip, I found a code which was "hidden" in my config file. – user3341592 Jun 22 '16 at 20:26
  • Without the code below, I don't even see any "Index" menu in my toolbar. Thought this should somehow be by default. – user3341592 Jun 22 '16 at 20:29
  • @lawlist If you post some kind of answer, I can give you the credit. – user3341592 Jun 23 '16 at 08:09
  • I'm glad you found a solution. I have no burning desire to post an answer, but thank you for asking anyway. If you are experiencing non-default behavior, then it may behoove you to track down the source of that cause and implement your fix at that juncture. Absent additional facts, you may have a situation of default behavior, where you change it to non-default behavior, where you subsequently change it again by using/abusing the `font-lock-mode-hook`. I menu is normally setup when enabling a major-mode, so consider a major-mode hook and also consider modifying `imenu-add-menubar-index`. – lawlist Jun 23 '16 at 14:09
  • Now that I confined the thing, can could be orient my searches, I found this: https://www.emacswiki.org/emacs/ImenuMode#toc2. This is where my chunk of code must come from... – user3341592 Jun 23 '16 at 14:45
  • So, you'd rather bind it to text-mode-hook and prog-mode-hook, right? – user3341592 Jun 23 '16 at 14:45
  • I would track down the modification in your configuration that changes "Index" to "Imenu" and strongly consider just changing that portion of code to read "Outline" instead. Or, I would safely eliminate that modification of default behavior, and consider a global or isolated modification. If isolated, then use a major-mode hook like the ones you mentioned. If a global solution is desired, then you can use this: `(require 'imenu) (defun imenu-add-menubar-index () "Doc-string." (interactive) (imenu-add-to-menubar "Outline"))` That is one method of redefining an existing function. – lawlist Jun 23 '16 at 14:50

1 Answers1

1

This is the code I found in my .emacs -- It is now adapted to name the menu "Outline" (instead of "Index" or "Imenu"):

;; Add Imenu to the menu bar in any mode that supports it.
(defun try-to-add-imenu ()
  (condition-case nil
      (imenu-add-to-menubar "Outline") ;; Imenu index
    (error nil)))
(add-hook 'font-lock-mode-hook #'try-to-add-imenu)

Thanks to @lawlist.

user3341592
  • 1,419
  • 1
  • 17
  • 36