How to set single click to enter directory in emacs speedbar? - emacs

I've got speedbar set up and working, but I want to change it so a single click (Mouse-1) will allow me to go inside a directory. I've already googled around and looked at the relevant docs:
The mouse bindings are:
Mouse-1
Move cursor to that location.
Mouse-2
Double-Mouse-1
Activate the current button. Double-Mouse-1 is called a double click on
other platforms, and is useful for windows users with two button mice.
So, basically I've been trying to find how to map Mouse-1 to the function currently bound to Mouse-2, but only inside the speedbar frame. The closest I've found to something to do that is an ecb setting:
(setq ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1)
but I'm not using ecb, I'm just using speedbar. Maybe there's some other way to do it?

Adding this line to `speedbar-file-key-map' should do the trick:
(define-key map (kbd "<down-mouse-1>") 'dframe-click)
If you don't want to edit speedbar.el directly, you can use e.g. a hook.

Related

How to set position of the lsp-ui-doc in spacemacs

I'm new to spacemacs and am having trouble with LSP as I'm also unfamiliar with the elisp language. I have a few things set up, but I can't for the life of me figure out how to set the position of the lsp-ui-doc to be under/above the cursor. I referenced the lsp-ui module on Github and it says that this can be configured, but I don't see any examples and I also don't know where I'd set it in my .spacemacs file.
Also, if anyone has any clues as to how I could have figured this out by myself, please let me know as well. I'd rather not have to resort to stack overflow to answer these questions if I can help it.
Any help would be greatly appreciated
For reference, the lsp-ui-doc shows up in the top right when the cursor is over some artifact:
Ok, so I was able to find the answer in the issues page on the github repo.
Short answer for this is to put '(lsp-ui-doc-position 'at-point) in the .spacemacs file under the heading (custom-set-variables. It should look something like this:
(custom-set-variables
'(lsp-ui-doc-position 'at-point)
Possible values for lsp-ui-doc-position are: top, bottom, at-point.
Take note of the warning here:
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
The appropriate way to do it is by following the instructions linked in this issue:
https://github.com/emacs-lsp/lsp-ui/issues/508
For anyone unfamiliar with the Customization option page, The buttons didn't work for me when I clicked them (though I'm certain there's a way to set this in emacs to work with clicks) but I had to put the cursor on the buttons I wanted to click and press enter. This brought up a context menu that allowed me to set the varables when I pressed enter on `Value Menu'.
"Clicking" (placing cursor and pressing enter) State allowed me to save it.

Context-insensitive completion popup in Emacs?

I'm experimenting with the transition from Vim to Emacs, and one of Vim's features that I really miss is the context-insensitve completion popup (CTRL-n and CTRL-p). For example, in the buffer below, if I were to type he then CTRL-n, I would get a popup:
How can I get a similar context-insensitive completion menu in Emacs?
Note: I specifically want context-insensitive because it's often helpful to make references across different contexts (for example, reference a Python class from Restructured Text documentation) — something context-sensitive "omnicomplete" doesn't do.
Additionally, I know that M-/ will trigger auto-completion, but it only cycles through matches; I want a popup list showing matches.
Auto Complete Mode should do what you're looking for.
It's generally not triggered by a hotkey, but something like:
(setq ac-auto-start nil)
(global-set-key "\M-/" 'auto-complete)
should do what you want.
Auto Complete Mode shows a dropdown menu with matches: http://cx4a.org/software/auto-complete/manual.html#Basic_Usage
You can install it via the Marmalade repository: http://marmalade-repo.org/, follow the instructions to setup Marmalade, then M-x package-install auto-complete. You'll have to activate auto-complete-mode, then while typing anything it will show you matches (you can also force it by pressing TAB, by default).

Autocompletion from the keyboard in Emacs CEDET/semantic

Looking a the different methods for completion in CEDET semantic (fresh version from the Bazaar repository), I see I have the following options (keyboard bindings as suggested by Alex Ott in his config file)
C-c ? (semantic-ia-complete-symbol)
C-return (semantic-ia-complete-symbol-menu)
C-c , l (semantic-analyze-possible-completions)
However, none of them seem to give me the option to choose between the possible completions conveniently using the keyboard.
For example, (semantic-ia-complete-symbol-menu) opens a menu where I can choose between the different options, but as far as I can tell it requires me to use the mouse (I tried C-n, C-p, M-n, M-p to navigate the menu with no success).
On the other hand (semantic-ia-complete-symbol) opens another buffer with the options. I can also use the mouse to choose the desired autocompletion, but I would like to use the keyboard instead.
Also, in previous versions of CEDET, there was a variable (semantic-complete-inline-analyzer-displayor-class) that allowed me to choose between several options for autocompletion (e.g. (semantic-displayor-ghost), or a more elegant overlay as a tooltip), but this variable does not seem to exist anymore.
In case it matters, I work mostly with C++ files.
Update:
The only method that seems to allow me to cycle through autocompletions is C-c , space (semantic-complete-analyze-inline), where I can use TAB to autocomplete, but it doesn't show a menu of possible autocompletions that I can choose from.
In new versions of CEDET it's recommended to use auto-complete or similar packages. You can add ac-semantic to ac-sources, and then auto-complete will use Semantic as source of data for completions. The new version of Emacs/CEDET articles, mentions this setup & shows necessary code. Please try it

Why does C+[up,down,left,right]arrow return [A,B,C,D] in emacs -nw (terminal a.k.a. "special interface") mode? and how can I get it to stop?

When I open an emacs buffer in the terminal using
emacs -nw
C+arrow does not move me around like I would like it to.
Is there a way to change this behavior?
There are two steps to fix this.
First find out what your terminal is sending emacs. This can be done right inside emacs by hitting C-q then the combination you want to see, say C-⇒ or something.
Then in your .emacs, you can bind the combination to whatever you want. For example, if you want C-⇒ to go to the next word, you can use (global-set-key "<your combination here>" 'forward-word). Do the same for the other bindings.
I have that sometimes in combination with screen. I run emacs as a daemon -- just disconnect that screen 'window' (or is it called panel or session?) and reconnect and you should be fine.
No idea what upsets the terminal settings.

Do you use Emacs tabbar?

The emacs tabbar.el package adds (buffer)tabs to each window and comes standard with aquamacs and can be added to emacs23 with the emacs-goodies-el package.
Are any of you hardcore emacs users actually using tabbar? I'm sort of used to having tabs, but I would like to know if working without them could be more productive, and if there are other ways besides checking your bufferlist (C-x C-b) to get an overview of your current project files.
As a side note, I really like textmate's project drawer (and tabs), but anything similar in emacs looks just plain hideous.
I've tried using it, but I felt it constraint my workflow rather than improve it. There are a lot of excellent Emacs modes to help with the organization of many buffers and I simply don't feel mapping buffers to tabs is one of those ways.
Just think about the most basic scenario - a lot of tabs. How different programs deal with it - limit the maximum tabs(IntelliJ IDEA); enable tabs bar scrolling(Firefox); infinitely reducing the tabs size(Google Chrome); creating rows of tabs(IntelliJ IDEA)... None of this solutions is that great and by not having tabs in Emacs we have one less problem to worry about. At least this is my subjective opinion - others will most certainly disagree... I personally need nothing more than ido and and iswitchb.
A video of ido in action: http://www.youtube.com/watch?v=lsgPNVIMkIE
Ya, I use tabbar, along with sr-speedbar.
I customize tabbar to show files in specific groups, and mod some keybindings to make navigating the files easier.
FWIW, here's the relevant section from my ~/.emacs:
(require 'tabbar)
; turn on the tabbar
(tabbar-mode t)
; define all tabs to be one of 3 possible groups: “Emacs Buffer”, “Dired”,
;“User Buffer”.
(defun tabbar-buffer-groups ()
"Return the list of group names the current buffer belongs to.
This function is a custom function for tabbar-mode's tabbar-buffer-groups.
This function group all buffers into 3 groups:
Those Dired, those user buffer, and those emacs buffer.
Emacs buffer are those starting with “*”."
(list
(cond
((string-equal "*" (substring (buffer-name) 0 1))
"Emacs Buffer"
)
((eq major-mode 'dired-mode)
"Dired"
)
(t
"User Buffer"
)
)))
(setq tabbar-buffer-groups-function 'tabbar-buffer-groups)
(global-set-key [M-s-left] 'tabbar-backward)
(global-set-key [M-s-right] 'tabbar-forward)
There's lot's of other tips on emacswiki:
http://www.emacswiki.org/emacs/TabBarMode
no.
I use iswitch-b
C-x b "first few letters of buffer", then C-s to rotate to the specific file I want takes me under 2 seconds without me having to move hand to mouse.
No. I could possibly be convinced to try it again with the right customisation, but by default it's pretty useless for me, as I habitually have in excess of 100 buffers open. ibuffer with its filtering and grouping is the best way for managing large numbers of buffers that I've tried.
I like to use speedbar for quick buffer navigation. I have in my .emacs
(speedbar-change-initial-expansion-list "buffers")
(global-set-key [f8] 'speedbar-get-focus)
so when I hit F8, a new frame pops up with a list of open buffers, there you can move point over the buffer you want to select and to activate it. One more F8 goes back to the main frame.
tabs are not reserved for mouse users. look at vim possible workflow: gt to go next tab, or gT to go previous. Say you've one dedicated window for vim: you might easily switch from one buffer to another. Yes, tabs are probably for users with few buffers. if you have hundreds, this won't work.
Quite frankly, you'll find better editors than emacs when speaking of tabs, menus and toolbar. Emacs clearly encourages you to use your keyboard and leave your mouse asleep.
Tabbar or any other tab management tool will have difficulties when you'll have lots of buffers opened. You also don't want to show all your buffers in tabs. Having to remove your hand from the keyboard to grasp the mouse and click on a tab and then remove your hand from the mouse and put it onto the keyboard is clearly a waste of time when a simple keystroke could be used instead.
The best thing you could do to your emacs and to you is to have the following configuration in your .emacs :
(menu-bar-mode -1) ;hide menu-bar
(scroll-bar-mode -1) ;hide scroll-bar
(tool-bar-mode -1) ;hide tool-bar
That will force you to forget the old way of doing things using a mouse (like using tabbar, or menus...), and to use your fingers instead.
Up until now, I haven't tried it, but before I switched back to GNU Emacs from XEmacs, I used the XEmacs tabs very heavily. I found that when I had many source files open, it was one of the fastest ways to jump to the correct file.
Now that I know about tabbar, I am trying it; and so far, I like it.
John
Tabs are really only useful if you use the mouse, and one of the main benefits (to me) of Emacs is that I can avoid the mouse.
So, no, tabbar isn't useful in general.
I did find the tabs useful when I was browsing web pages (using w3m), but I was using the mouse in that case...
Tabbar looks like it is godforsaken
So what about elscreen?
Can be found via http://melpa.milkbox.net/#/elscreen - or installed emacs-elpa (or melpa).
Elscreen is very useful for me.
C-x b<RET> always gives you the last edited buffer. And what do you do with tabs ? Mostly switch back & forth between two files. There you go.