Instead of using imenu, you can use org-goto with the following
(setq org-goto-interface 'outline-path-completionp)
(setq org-outline-path-complete-in-steps nil)
,----[ C-h v org-goto-interface RET ]
| org-goto-interface is a variable defined in ‘org.el’.
| Its value is ‘outline-path-completionp’
| Original value was outline
You need to make AUCTeX aware of the frame environment, i.e., \frametitle:
(add-to-list 'TeX-outline-extra '("\\\\frametitle\\b" 4))
From the documentation on Tex-outline-extra:
List of extra TeX outline levels.
Each element is a list with two entries. The first entry is the
regular expression matching a header, and the second is the level of
You can use imenu-mode for that purpose. It comes shipped with emacs and most programming modes support it.
EDIT2: You could simply start it with this:
(add-hook 'prog-mode-hook (lambda () (imenu-add-to-menubar "Imenu")))
EDIT: I activate it by this code:
(defun my-try-to-add-imenu ()
(condition-case nil (imenu-add-...
The interesting function here is imenu--generic-function which by skips comments and string by inspecting the value of syntax-ppss. So it should have worked out of the box for you. Looking at the code it seems to jumps to the start of the before checking for output of syntax-ppss, I guess that is screwing up things for you (since it might move out the ...
You don't have to create a one-liner. The following list of definitions should create an imenu items:
'((nil "\\(^@font-face\\)" 1)
(nil "\\(^body\\)" 1)
(nil "\\(^#foo\\)" 1)
(nil "\\(^h\\)" 1)
(nil "\\(^\.CheltenhamBT-BoldHeadline\\)" 1)
Vanilla imenu presents things hierarchically, so you'd first have to choose between Public/Private/All functions, before you actually chose from a list of actual function. However, this is confusing with other imenu frontends that show them all at the same time.
There are distinct entries in the imenu-generic-expression value that php-mode defines for ...
I copied over the definition of the variable cc-imenu-c++-generic-expression and patched the regular expressions that included ^ to ^[ \t]*. Eval the setq (maybe put it in your init.el, then open the test file.
;; Try to match ::operator definitions first. Otherwise `X::operator new ()'
;; will be incorrectly ...
In a buffer with only the line const char* fileName as above, running (semantic-fetch-tags) returns this tag that gives back char as type:
(("filename" variable (:pointer 1 :constant-flag t :type "char") nil #<overlay from 1 to 22 in 03-095759.c>))
The type is "char", although it has the attribute :pointer 1 to denote the level of pointer. helm-...
(defun my-imenu-goto--closest-dir (direction)
"Jump to the closest imenu item on the current buffer.
If direction is 1, jump to next imenu item.
If direction is -1, jump to previous imenu item.
Adapted from `which-function' in::
(push '("frametitle" 2) TeX-outline-extra)
See the documentation for TeX-outline-extra. The first element of the list being added is a regexp and the second is the imenu level. You can also see LaTeX-section-list for the default levels that imenu uses for latex.
As suggested in the comments, it might be a little safer to use the ...
It is possible to represent structured menu with imenu.
A valid alist shape could be:
(list "Title 1"
(list "Title 11"
'("Index Name 1" . 1)
'("Index Name 2" . 1)))
(list "Title 2"
'("Index Name 21" . 1)
'("Index Name 22" . 1)))
The error was caused by quoting of '(("sub-item" . 1)) form.
I think that I misunderstood what the OP asked for. He wished to search for matches to arbitrary regexps not simply within the matches found by the usual imenu. This can be done.
(defun imenu-match-insert (s)
(interactive "sRegexp to search with: ")
(let ((imenu--index-alist nil)
(imenu-generic-expression (list (list nil s 0))))
This does what you ask for.
(defun imenu-insert-label (s)
(interactive "sRegexp to search with: ")
(insert (completing-read "Choose a target: "
(seq-filter (lambda (z)
(string-match s (car z)))
My solution is way too hacky:
A file that you want to have Imenu to access is likely to be tracked by Git.
Use find-file-noselect on all those files (I don't know how to detect binary files with Emacs so limiting on VCS-tracked files is better), and accept the risk of hooks and advices, auto-loading functions, etc.
I'm not really sure what you're trying to do, but maybe this will help:
(defun foo ()
(global-set-key (kbd "<f4>") 'foo)
This makes the rescan item an empty string, maybe that's good enough.
(setq imenu-auto-rescan t
imenu-auto-rescan-maxout (* 1024 1024)
imenu--rescan-item '("" . -99))
Here's some advice on some internal imenu functions that actually removes the rescan item. I think I got the corner cases, but it might break in the future.
The comment of user poliza provided the following solution based on
pdf-outline--imenu--split-menu from pdf-tools.
;; See http://emacs.stackexchange.com/questions/31791/order-of-items-in-imenu?noredirect=1#comment48799_31791
(advice-add #'imenu--split-menu :around #'reftex-outline-imenu--split-menu)
(defun reftex-outline-imenu--split-menu (oldfun menulist ...
Fixed it by changing the value of imenu-generic-expression to
'(("type" "^[ \t]*type *\\([^ \t\n\r\f]*[ \t]*\\(struct\\|interface\\)\\)" 1)
("func" "^func *\\(.*\\)" 1)))
Which has two advantages over the original value. it recognizes split-line functions, and it notices embedded types.
I'll probably submit a PR to go-mode, but until then to get this ...
Hoping below function would help
;;; add func to perform imenu for all headings at one level
(defun org-imenu-get-heading ()
"Produce the index for Imenu."
(mapc (lambda (x) (move-marker x nil)) org-imenu-markers)
(setq org-imenu-markers nil)
(let* ((n org-imenu-depth)
(re (concat "^" (org-get-limited-outline-regexp)))
It turned out that I have installed a package called lispy and that this package seems to change imenu-create-index-functions value.
Answering my own question gives me the impression that doing "emacs -Q" should have been my pre-post action... Since I had not time to get used to lispy I just removed the package and now i can imenu through my init.el again!
Load the source file imenu.el, then use M-x debug-on-entry RET imenu-choose-buffer-index. Open file imenu.el in a separate frame (C-x 5 f), and move to the definition of imenu-choose-buffer-index, so you can see what it does.
Then, when you try to invoke imenu the debugger will open. You can walk through the debugger using d (or c to skip through an ...
I've just patched
to properly handle const char* fileName.
It seems that semantic can't currently parse top-level references. Although it parses them
in the arguments lists, as you can see here: