When using Icicles in emacs, how do I get *just* the definition with a tag lookup? - emacs

In vanilla emacs, I load the TAGS file, and do a lookup of a symbol with "M-.". I go right to the definition of the symbol.
When using Icicles, I get 374 hits for the same symbol. While I can in theory chip away the non-elephant slowly to find what I want, that's a pain, and I end up just turning off icicles for the tag lookup, and turning it back on.
Is there any way to tell icicles that I just want the definition when I do a tags lookup, and not every relevant match in the tags file?
For instance, I might search for the definition of the task_struct structure in the linux kernel source code. I see many definitions of the form:
struct task_struct taskInfo;
struct task_struct info;
but all I want is the one definition:
struct task_struct {
While I can "chip away the non-elephant, the elephants are pretty similar here, and it is hard to tell while looking at the search results that I only want lines with a curly brace after the name, and the curly brace might have been on a different line anyhow, so there is no guarantee even that is the right way to slice the results.
I've also seen member functions of a class appearing when I use Icicles, and I'd like a way to turn them off more easily.
Tried reading the emacs wiki and an internet search, but I didn't have much luck just searching for "emacs icicles tags".

If vanilla M-. does what you want, doesn't icicle-find-first-tag' also do what you want? (Notice the-first'.)
http://www.emacswiki.org/emacs/Icicles_-_Emacs_Tags_Enhancements#icicle-find-first-tag

I don't use icicles, so I don't know if this will actually work, but give it a whirl and let me know.
(defadvice find-tag (around my-thawed-find-tag)
"Disable icicles when finding tags."
(let ((icy-state icy-mode))
(if (not (equal (icy-mode 0)))
(progn
(icy-mode 0)
ad-do-it
(icy-mode icy-state))
ad-do-it)))
(ad-activate 'find-tag)

The advice around find-tag wasn't really what I was looking for. Instead, what I need is a way to get the definition sometimes and references sometimes. I found that cscope and the xcscope.el plugin did what I needed (and CEDET also did something similar to solve my problem)

Related

How to make emacs completing-read display *Completions* buffer as soon as I type

In emacs lisp, I expect the following to display a list of options in the completion buffer as I type. It prompts for information but doesn't display choices, either before or after I start typing. For example, I'd expect it to display 'First' after I'd typed 'F'.
(defun reader ()
(interactive)
(let ((choices '("First" "Second" "Third")))
(completing-read "Choose: " choices)))
Essentially I'm looking for something similar to the output described here. But what I get is this (there's nothing below the line, which is the edge of my window):
Can anyone explain where I'm going wrong with completing-read?
That's the way completing-read behaves. You're not doing anything wrong. It just doesn't support any kind of automatic, incremental completion.
If you want such automatic completion then you either need to write your own code to provide that or use a completion framework that provides it.
Icicles was the first to provide this incremental-completion behavior. Many other packages now provide the same or similar.

Emacs 26 flymake: customizing the mode line format

I'm considering switching back from flycheck to flymake after the Emacs 26 rewrite. One thing that bothers me about flymake is how much room on the mode line it takes up. It has a string Flymake plus the results. It seems like a silly thing but this is 10% of the mode line on an 80-char frame, just for a name! I have lots of important info I'd like to see on my mode line so I try to remove things that aren't helpful to me--I know what minor modes etc. are enabled in my buffers, since I configured them! Personally I'd prefer to not see a name at all, just the results, or at most F or FM.
I could use diminish to get rid of the mode line info completely but of course I don't want that: I want to be able to see the state of my buffer.
I took a look at flymake.el and the flymake--mode-line-format defun and it doesn't seem like this string is configurable, or easy to change at all.
Anyone have any thoughts about this?
You'd need to redefine flymake--mode-line-format function. It should probably be more customizable, but it's not. Possibly the least intrusive way to do it is to define :filter-return advice on that function to transform the output.
(defun flymake--transform-mode-line-format (ret)
"Change the output of `flymake--mode-line-format'."
(setf (seq-elt (car ret) 1) " FM")
ret)
(advice-add #'flymake--mode-line-format
:filter-return #'flymake--transform-mode-line-format)

how to prevent helm-swoop from returning symbol at point?

I would like to invoke M-x helm-swoop such that it does NOT return the symbol at point. I find that it always picks up undesired symbols, e.g. when I invoke M-x helm-swoop in org-mode, I get Swoop: \*, and I then have to delete the \* before I can enter my desired search term. How can I do this?
This has been bugging me as well, for exactly the same reason (swoop in an Org-mode buffer picking up heading characters), so this question motivated me to go and look.
Looking at the source, Helm-swoop calls helm-swoop-pre-input-function to populate the prompt, and by default this is set to a function that returns (thing-at-point 'symbol), which is what causes the problem in headings.
A quick test with the following in my init file seems to work:
(setq helm-swoop-pre-input-function
(lambda () nil))
This could certainly be improved by, for example, keeping the default behaviour in non-Org buffers but as I'm only really using swoop in Org buffers this is good enough for me.

Emacs / Slime Key Binding / Sending command to Swank Server

I'm familiar with scheme, but new to emacs (switching over from VIM) and elisp.
I know how to do the following:
make a simple key binding
C-c iwb = indent whole buffer
F2 = turns folding on/off
use slime from emacs
some basic keys, like C-x 2, paredit keys, some basic movement keys
I need help doing something a bit more advanced:
I want F3 to equal:
put emacs into C-x 2 mode
in bottom window, switch to "slime-repl" buffer
in the "slime-repl" buffer, send the command "(test/run)" <-- note, this is meant to be sent to the swank server, NOT to elisp
I realize it's terrible form to ask people to write a script for me; however, if anyone could do that, I would learn rather quickly from it. [And it would allow me to do more complicated types of scripting through studying your example.]
Thanks!
This is not exactly what you want, but should be a good starting point for further tweaking:
(defun slime-run-test ()
(interactive)
(slime-interactive-eval "(test/run)")
(slime-pop-to-buffer (slime-output-buffer) t))
(global-set-key (kbd "<f3>") 'slime-run-test)
I don't use slime, but assuming it uses comint-mode then I would think the following might do the trick:
(defun my-slime-test-run ()
(interactive)
(delete-other-windows)
(split-window-below)
(with-selected-window (next-window)
(switch-to-buffer "slime-repl")
(goto-char (point-max))
(insert "(test-run)")
(comint-send-input)))
(global-set-key (kbd "<f3>") 'my-slime-test-run)
There is probably a better way to do this, but hopefully that gives you a little insight into how you can write elisp functions to carry out tasks in the editor (and note how the function reads very much like a set of editor instructions -- you can do a lot simply by converting the keystrokes you would use into equivalent code -- or even not writing code at all, and simply recording & saving keyboard macros).
Use C-hf name-of-the-function RET to get documentation on any of the function/macro calls in that function.
For the keybinding, I used C-hkF3 to check how Emacs referred to that key, and then used that string as the argument to kbd (and note how you can use that sequence to find the name of the function bound to any given key sequence, which you can then utilise in code if desired).
Many things are far less obvious if you don't already know them, but that's only to be expected with a code base as large as this (and dating back as long as this).
The great thing is that if you don't know what you're looking for, you can always search for function names matching patterns with C-uC-ha (and similarly for variables, values, libraries, and documentation; see M-: (info "(emacs) Apropos") RET for more about this facility). Plus the info manuals (complete with indexes -- press I or i within any particular manual, or use the info-apropos command to search all info manuals at once).
Truly one of the very best things you can do is to learn how to use the self-documenting nature of Emacs to find answers to the things you don't already know.

Debugging emacs LaTeX config file without trial-and-error binary search

I have an extensive emacs configuration. Unfortunately, auto-fill-mode is broken within LaTeX-mode for some reason. How can I debug this without binary searching my emacs configuration for the error?
Alternatively, how can I make this function not set an undo point? It's annoying to have to press undo once per word and space in the document.
(local-set-key (kbd "SPC")
(lambda () (interactive) (fill-paragraph)
(insert " ")))
Well, you can try M-x debug-on-entry auto-fill-mode.
But my advice would be to use do the binary search you're trying avoid. There is nothing faster. My init setup is probably at least as extensive as yours, and I sometimes think there is a quicker way to guess what the problem is, and time and again I've been taught the lesson that binary search is the way to go. It just seems slow and silly at first.
Remember the parable of the wise man who convinced a ruler to pay him with one grain rice on the first chessboard square, 2 on the second square, 4 on the third, and so on. It really doesn't get any better than binary search when you have no idea where the problem is, and even often when you think you can guess the general location of the problem. Just do it.