How to change SPC bind in info-mode - emacs

I have this on my init.el and I still did not manage to make SPC do what I want in info-mode:
(unbind-key "SPC" Info-mode-map)
(unbind-key "SPC" Info-edit-map)
(unbind-key "SPC" Info-edit-mode-map)
(unbind-key "SPC" Info-link-keymap)
(unbind-key "SPC" Info-mode-line-node-keymap)
(unbind-key "SPC" Info-speedbar-key-map)
(unbind-key "SPC" info-tool-bar-map)
(bind-key "w" 'Info-scroll-up Info-mode-map)
(bind-key "SPC" 'counsel-M-x Info-mode-map)
What am I doing wrong?

You don't need bind-key or unbind-key. And you don't need to do any of the stuff you tried doing (seemingly blindly). Just do this:
(define-key Info-mode-map (kbd "SPC") 'counsel-M-x)
Do that after loading Info (e.g., do it on Info-mode-hook).
If that doesn't work then you are doing something else in your init file that interferes. In that case, recursively bisect your init file to find the problem.

Related

Initialization Issue Starting Emacs 27.1 in Daemon Mode on Windows 10

After following instructions from https://www.emacswiki.org/emacs/EmacsMsWindowsIntegration
on starting emacs 27.1 as daemon in windows 10 where path\to\emacs is
"c:\emacs-27.1\bin\runemacs.exe --daemon , see here:
You can also open Explorer, type in shell:startup in the address bar, and press enter. In this startup >folder, create a shortcut by right clicking and selecting new->shortcut. When asked for location, put >the following: "X:\path\to\emacs\bin\runemacs.exe" --daemon where you have substituted the proper path >to runemacs.exe. This shortcut will run at startup. You can double click on the shortcut to start the >Emacs server if it is not already running.
Emacs daemon loads initialization file in c:/emacs-27.1/.config/emacs/init.el and properly so far defines ever function, only there are key-bindings initialized in the init and listed under describe-personal-keybindings that don't work when emacsclientw.exe starts.
They are bindings that were initially reserved for windows and decoded then recoded in the init.
This guy, for example, doesn't play nicely (nothing happens after C-m) in a client connected to a daemon, but works just fine when emacs is started with a frame.
(define-key input-decode-map [?\C-m] [C-m])
; translate it as synonymous with <apps> key
(define-key key-translation-map (kbd "<apps>") (kbd "<C-m>"))
;create a prefix command
(define-prefix-command 'super-keymap)
;set C-m as the prefix-command (note s- is also enabled now, so all C-m can be run with s-)
(global-set-key (kbd "<C-m>") super-keymap)
The same bug occurs after rebinding these guys C-[ and C-]
;rebind C-] keys
;rebind abort-recursive-edit, ESC will work on windows
(global-unset-key (kbd "C-]"))
(define-key input-decode-map (kbd "C-[") [control-bracketleft])
(bind-key [control-bracketleft] 'sp-backward-sexp)
(global-unset-key (kbd "C-]"))
(define-key input-decode-map (kbd "C-]") [control-bracketright])
(bind-key [control-bracketright] 'sp-forward-sexp)
The daemon doesn't of course open up a frame when it launches, hence likely it's in terminal mode. Maybe those keys on windows are not accessible from the same commands in terminal mode? Or is something else going on here?
Any takers?
Solution for me was to run the client with arguments.
pathTo/emacsclientw.exe -n -c -a "" -e "(rebind-keys)"
(defun rebind keys ()
(progn
(bind "C-x" 'bound-function-x')
(bind "C-y" 'bound-function-y')))

Change :ls to bring up ibuffer in Emacs evil-mode

Out of the box, :ls in evil-mode invokes M-x list-buffers. What do I need to put into my .emacs to rebind this to run M-x ibufferinstead?
Changing this has nothing to do with evil-mode: (defalias 'list-buffers 'ibuffer)
Specifying (defalias 'list-buffers 'ibuffer) didn't work for me.
In looking at source file 'evil-maps.el' I found another method.
Add to your .emacs file:
;; bind ':ls' command to 'ibuffer instead of 'list-buffers
(evil-ex-define-cmd "ls" 'ibuffer)
This method should be able to map any evil ex command.

How do I automatically get paredit in a emacs nrepl session?

I have the following line in my emacs init file.
(setq auto-mode-alist (cons `("\*nrepl\*" . paredit-mode) auto-mode-alist))
I check that this works by creating a new buffer called *nrepl* Ctrl-x-f *nrepl*. Yes, the *nrepl* buffer has Paredit active, paredit-mode was enabled.
I close the *nrepl* buffer without saving it.
I start up a nrepl session by typing M-x nrepl-jack-in. The nrepl server starts up and I am presented with the nrepl repl. The nrepl repl is also called *nrepl*, however Paredit is not enabled.
What am I doing wrong?
You're confusing buffers and files: auto-mode-alist matches file names against regexps to decide which mode to use when editing those files. But *nrepl* is a buffer that does not contain a file, so auto-mode-alist has no effect for it.
Instead, you probably want to figure out which major-mode *nrepl* uses and then use (add-hook '<the-major-mode>-hook 'paredit-mode).
To put it simply - you need the following code:
(add-hook 'nrepl-mode-hook 'paredit-mode) ; for nrepl.el <= 0.1.8
(add-hook 'nrepl-repl-mode-hook 'paredit-mode) ; for nrepl.el > 0.1.8
Which is equivalent to the longer form:
(add-hook 'nrepl-mode-hook (lambda () (paredit-mode +1)))
(add-hook 'nrepl-mode-hook 'paredit-mode)
is what they suggest on the nrepl github page

Emacs + Synctex + Skim: How to correctly set up synchronization? [none of the existing methods worked properly]

I'm working with GNU Emacs 23.3 (9.0) on Mac OS X 10.7.2. I would like to use synctex to jump between .tex and .pdf files. Although there are many different approaches on the web, none worked properly (I tried 8 different approaches...). I finally ended up with the rather simple approach described here: http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=TeX_and_PDF_Synchronization
So my .emacs contains:
'(LaTeX-command "latex -synctex=1")
(require 'tex-site)
(add-hook 'TeX-mode-hook
(lambda ()
(add-to-list 'TeX-output-view-style
'("^pdf$" "."
"/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b")))
)
(server-start)
Of course, I also set up Skim (Preferences -> Sync -> checked "Check for file changes" and chose Preset: Emacs with command emacsclient and arguments --no-wait +%line "%file")
As you can see, I included the -b option to displayline. I can call displayline from the terminal and it opens the .pdf and displays the corresponding line with a yellow/highlighted bar. Still, nothing is displayed on the current line if I compile the document with latexmk -pvc -pdf from a shell within Emacs.app.
Question 1: How can I get this to work/How can I display the current line?
Question 2: Is it possible to have a "proper" forward search by clicking the .tex and jumping to the corresponding line in the .pdf document? How can I "click" in emacs? The standard CMD + shift + click does not work in emacs.
I also tried approaches using...
(setq TeX-source-correlate-method 'synctex)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
... but nothing changes.
I can CMD + shift + click in the .pdf and jump to the .tex, so that works.
The only directions which I haven't looked into are:
is this a latexmk problem? Most likely not, since latexmk explicitly displays pdflatex -interaction=nonstopmode -synctex=1 so synctex is recognized
is it a wrong skim preference setting? Maybe I have to adjust the arguments to emacsclient there (?)
Solution
Indeed latexmk is the problem. I finally figured out the following settings:
~/.emacs
;; make latexmk available via C-c C-c
;; Note: SyncTeX is setup via ~/.latexmkrc (see below)
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run latexmk on file")
TeX-command-list)))
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))
;; use Skim as default pdf viewer
;; Skim's displayline is used for forward search (from .tex to .pdf)
;; option -b highlights the current line; option -g opens Skim in the background
(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
'(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")))
(server-start); start emacs in server mode so that skim can talk to it
~/.latexmkrc
$pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S';
$pdf_previewer = 'open -a skim';
$clean_ext = 'bbl rel %R-blx.bib %R.synctex.gz';
This perfectly allows to compile with latexmk as default on C-c C-c and C-c C-v opens Skim at the current line which is nicely highlighted. With CMD + shift + click in the .pdf, one can then jump back to the corresponding paragraph in the .tex file (thanks to server-start).
To enable the clicking feature of the sync, I added:
(add-hook 'LaTeX-mode-hook
(lambda () (local-set-key (kbd "<S-s-mouse-1>") #'TeX-view))
)
to my .emacs file.
NOTE: make sure that you are in PDF mode (use (setq TeX-PDF-mode t)).
When you press C-c C-v (which runs TeX-view) it should open Skim with the bar on the current line. This is what you set up with the TeX-output-view-style. You can't get that behaviour from latexmk -pvc since it doesn't know which line you are on. All latexmk knows is that the file changed. In order to do a forward search you need to run TeX-view.
You can bind CMD + shift + click to run TeX-view by adding
(define-key LaTeX-mode-map [M-S-mouse-1] 'TeX-view)
or possibly
(define-key LaTeX-mode-map [s-S-mouse-1] 'TeX-view)
to your TeX-mode-hook. It depends on your settings which you need, but can find out by pressing C-h C-k and then CMD+shift+click. Of course adding both shouldn't cause a problem.

Enabling control-c and control-v copy and paste in Emacs

How do I copy & paste in Emacs with ctrl+c and ctrl+v?
What must I add to my .emacs file?
Check out the Cua Mode.
Old question, but nevertheless.
Unbind Ctrl+C because it's modifier in Emacs:
(global-set-key (kbd "C-c") 'undefined)
Bind Ctrl+C to Copy:
(global-set-key (kbd "C-c") 'kill-ring-save)
Bind Ctrl+V to Paste:
(global-set-key (kbd "C-v") 'yank)