how to get started with viper/vimpulse? - emacs

I obtained a git clone of vimpulse and followed the instructions for installation. It basically says to put (require 'vimpulse) in my .emacs file - but this will start viper/vimpulse upon startup, so I tried to have vimpulse load only if I invoke viper-mode with (add-hook 'viper-mode-hook (lambda () (require 'vimpuse)). But when I do this visual mode does not work (tries to open file instead), so instead I now have something like (defun vimpulse-on () (interactive) (require 'vimpulse)). After that to toggle on and off I use C-z. Does that about sound right? So once vimpulse is loaded there's no equivalent of M-x viper-go-away and instead it's suspended until I hit C-z again... Also, any general tips with using viper/vimpulse would be appreciated! Thanks much in advance.
Edit: syntax error corrected. What I had tried was (add-hook 'viper-mode-hook (lambda () (require 'vimpulse)), which does not enable visual mode when viper-mode is started. v in normal-mode appears to be mapped to find-file (or ido-find-file).

(add-hook 'viper-load-hook
(lambda () (require 'vimpulse))
Just load vimpulse in the viper-load-hook.

Related

How to turn on evil mode on emacs startup

I've been using nvim for a while and recently thought about checking emacs out after learning about evil mode. I made init.el in .config/emacs, installed evil mode and figured i would try to enable it whenever i start up emacs.
So i wrote this bit of code in init.el:
(defun evil-mode-on ()
(require evil)
(evil-mode 1))
(add-hook 'after-init-hook 'evil-mode-on)
But unfortunately it doesn't seem to work and i'm not sure what i'm doing wrong. Any help would be very much appreciated and thanks in advance.
You seems to be missing apostrophe(') in require. It should be (require 'evil)
Enabling evil mode at startup could be as simple as specifying
(require 'evil)
(evil-mode 1)
in your init.el file as long as package is already installed and/loaded.
Github page has in detailed instruction to install it automatically with the help of use-package.

emacs can't turn on minor-mode automatically

I want irony-mode be turned on automatically in c-mode. But I have tried two ways, both fail. Can someone teach me? I don't like to type M-x irony-mode always.
1:
(require 'irony)
(defun my:irony-init ()
(irony-mode 1))
(add-hook 'c++-mode-hook 'my:irony-init)
(add-hook 'c-mode-hook 'my:irony-init)
OR 2:
(require 'irony)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
I find not only irony-mode, but also ggtags and flycheck can't load through add-hook. I have (add-hook 'c-mode-hook 'flycheck-mode), but it doesn't work. Can someone help me? My .emacs.d has uploaded to github:https://github.com/cfampc/emacs.d。 My irony-mode is configured in .emacs.d/custom/c-settings.el and flycheck ggtags is in .emacs.d//custom/edit-settings.el. Before I can have ggtags-mode auto-load in C. Now, If I add (add-hook 'c-mode-common-hook 'irony-mode) after (load ...) all of my config file, it does work. But if I add it in .emacs.d/custom/c-settings.el , It doesn't work. why?
That should work fine, so you should recursively bisect your config to find the source of the problem.

How to enable `fill-column-indicator` on startup

I am using Aquamacs on OS X 10.9.4. I have the following lines in my Preferences.el file
(which is similar to the .emacs init file):
(add-to-list 'load-path "~/.emacs.d/")
(require 'fill-column-indicator)
(setq-default fci-mode t)
I use M-x fci-mode to manually toggle the column indicator.
How can fci-mode be enabled on startup using Aquamacs?
Don't put ~/.emacs.d itself in your load-path. Always use a sub-directory.
e.g.: use ~/.emacs.d/lisp/fill-column-indicator.el and:
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))
(require 'fill-column-indicator)
This library doesn't provide a global minor mode, but you can make one yourself like so:
(define-globalized-minor-mode my-global-fci-mode fci-mode turn-on-fci-mode)
(my-global-fci-mode 1)
or toggle it interactively with M-x my-global-fci-mode RET
You should remove (setq-default fci-mode t).
fci-mode is not global, so you could use a mode hook. If, for example, your opening document on startup is emacs-lisp-mode, you could place something like this inside your Preferences.el file.
(add-hook 'emacs-lisp-mode-hook (lambda ()
(fci-mode 1)
))
You will need to use a mode hook for each major mode; or, you will need to modify fci-mode by adding a global setting.
For anyone who is interested in looking at the source-code, here is the link to the Github repository: https://github.com/alpaker/Fill-Column-Indicator
With Emacs 27 comes the display-fill-column-indicator-mode minor mode, which obsoletes the fill-column-indicator package. You can add:
(add-hook 'prog-mode-hook (lambda ()
(display-fill-column-indicator-mode)))
to ~/.emacs to enable it for prog-mode buffers, or:
(global-display-fill-column-indicator-mode)
to enable it globally. To toggle it, use M-x display-fill-column-indicator-mode.

How to connect Hyperspec documentation to Emacs SLIME on MS Windows

With this minimal init file:
(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")
Everything seems to work, such as slime-eval-defun and slime-complete-symbol, except for looking up documentation. M-x slime-describe-symbol RET print RET results in this error:
CLHS-ROOT: variable *CLHS-ROOT-DEFAULT* has no value
What do I need to add in my init file to make it work?
I also tried downloading the hyperspec tar file and extracting it to a directory, and this code:
(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp"
common-lisp-hyperspec-root "c:/run/HyperSpec/"
common-lisp-hyperspec-symbol-table "c:/run/HyperSpec/Data/Map_Sym.txt")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")
That doesn't work either. I do not know if the bug is in that init file, or in the SLIME version I am using, because this is my first time with SLIME.
Versions:
MS Windows 7
Emacs version 24.3.1 (probably latest stable)
SLIME version 20130626.1151 (latest from MELPA) (One from Marmalade says it can't compile nil, I don't know what that means and so I am using one from MELPA instead)
GNU CLISP 2.49 (latest stable)
UPDATE
C-c C-d f RET print RET works fine. This is bound to slime-describe-function, which is undocumented, and not listed in SLIME menu. There is also slime-documentation-lookup which is bound to C-c C-d C-d which can open documentation for variables (not just functions) in a browser, and that works too. Looks like only `slime-describe-symbol doesn't work.
I haven't done it on Windows, but if I were you, I'd try to do this with Quicklisp: (ql:quickload "clhs") and follow the printed directions.
I'd also get SLIME from Quicklisp via (ql:quickload "quicklisp-slime-helper"), but if your slime works ok, no real need.
Assuming that SLIME is installed from an emacs package archive (preferably MELPA) (and that GNU CLISP is installed), here is combination of relevant portions from How to install Common Lisp and SLIME on MS Windows:
Assuming starting from scratch after commenting out any SLIME customization code you already have, start by putting the following code to your init file which should be evaluated after package-initialize:
(setq inferior-lisp-program "clisp")
(setq slime-auto-connect 'ask)
(defun my-slime-setup ()
(require 'slime)
(slime-setup))
(defvar my--slime-setup-done nil)
(defun my-slime-setup-once ()
(unless my--slime-setup-done
(my-slime-setup)
(setq my--slime-setup-done t)))
(defadvice lisp-mode (before my-slime-setup-once activate)
(my-slime-setup-once))
What that does is defining my-slime-setup and make sure the function runs just once if you are using SLIME that day. my-slime-setup is also a container to which you can add your own SLIME customization code.
Now to connect the downloaded documentation to SLIME, extract the downloaded archive and you will get a folder with name Hyperspec, and then you move that folder to the Emacs bin directory, or its parent directory, or its grandparent directory, Put the following code in Emacs init file.
(defun my-hyperspec-setup ()
(let ((dir (locate-dominating-file invocation-directory "HyperSpec/")))
(if dir
(progn
(setq common-lisp-hyperspec-root (expand-file-name "HyperSpec/" dir)))
(warn "No HyperSpec directory found"))))
and add my-hyperspec-setup to my-slime-setup like this:
(defun my-slime-setup ()
(my-hyperspec-setup)
(require 'slime)
(slime-setup))
and restart Emacs.
And now when you do M-x slime-describe-symbol RET print RET in a lisp buffer, it should show the description of PRINT in another buffer.
I should confess that I am sourcing from my own article and also answering my own question after about 8 months. The answer is tested with latest SLIME from MELPA and on a vanilla GNU Emacs.

Emacs auto-complete mode for Groovy?

Is there a Groovy compatible auto-complete mode for emacs?
I also was not able to find a keyword dictionary that I can use with emacs autocomplete.
Help would be much appreciated.
AFAIK there is no working (intelligent) auto-complete for Groovy. If you are inclined to a bit of hacking, the easiest way to achieving this would be to modify emacs-eclim (an Emacs package for talking to Eclipse) to work with the Eclipse Groovy plugin. Shouldn't be that bad, as there is existing code for working with Eclipse Java that you could use as scaffolding.
HTH and sorry :(
I have 'hacked' both emacs-eclim and Eclim to get code completion, not pretty or feature-complete, good enough for few hours of work.
1. Notes:
Code completion is supported, but it is slow with auto-complete-mode sometimes, especially when completion is triggered automatically. I use TAB to start the autocomplete popup and ALT-TAB for the completions buffer, if I'm looking up all possible completions.
Source update for issues reporting is supported but not fully accurate. As you save the buffer an incremental build is performed and the errors report is available (Problems via C-c C-e o.
If using auto-complete, set the following:
(ac-set-trigger-key "TAB")
(setq ac-auto-start nil)
2. Installation
git clone https://github.com/yveszoundi/eclim
cd eclim && ant -Declipse.home=YOUR_ECLIPSE_FOLDER
git clone https://github.com/yveszoundi/emacs-eclim
Add emacs-eclim folder to your load-path
3. Sample Emacs configuration via use-package and ELPA.
If you don't use use-package, adapt as needed...
(use-package eclim
:ensure emacs-eclim // overwrite ELPA install with my copy
:init (setq help-at-pt-display-when-idle t
eclimd-default-workspace "~/Documents/workspace/"
help-at-pt-timer-delay 0.1)
:config (progn (help-at-pt-set-timer)
(mapc #'require '(eclimd auto-complete-config))
(ac-config-default)
(add-hook 'groovy-mode-hook 'auto-complete-mode)
(require 'ac-emacs-eclim-source)
(ac-emacs-eclim-config)
(defun ers/eclim-run-class ()
(interactive)
(beginning-of-buffer)
(search "class ")
(forward-word)
(eclim-run-class))
(bind-keys :map eclim-mode-map
("C-c C-e l m" . eclim-manage-projects)
("C-c C-e l r" . ers/eclim-run-class)
("C-c C-e l c" . garbage-collect)
("C-c C-e l b" . eclim-project-build))
(add-hook 'groovy-mode-hook
(lambda ()
(remove 'ac-source-clang 'ac-sources)
(eclim-mode t)))
(add-hook 'java-mode-hook
(lambda ()
(remove 'ac-source-clang 'ac-sources)
(eclim-mode t)))))