I use ergoemacs-mode, clojuremode and autocomplete
Autocomplete works very well. What should I press to go to definition of a function? I get used to Cursive, but I want to use free Emacs and I needed go to definition feature.
Here is my init.el file:
(global-set-key [f8] 'neotree-toggle)
;; Set bigger fonts
(set-default-font "Ubuntu Mono-16")
(add-hook 'clojure-mode-hook 'turn-on-eldoc-mode)
(setq nrepl-popup-stacktraces nil)
(add-to-list 'same-window-buffer-names "<em>nrepl</em>")
;; General Auto-Complete
(require 'auto-complete-config)
(setq ac-delay 0.0)
(setq ac-quick-help-delay 0.5)
(ac-config-default)
;; ac-nrepl (Auto-complete for the nREPL)
(require 'ac-nrepl)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-to-list 'ac-modes 'cider-mode)
(add-to-list 'ac-modes 'cider-repl-mode)
(add-hook 'clojure-mode-hook 'paredit-mode)
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "http://melpa-stable.milkbox.net/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
;; Initialize all the ELPA packages (what is installed using the packages commands)
(package-initialize)
;;(package-initialize)
(require 'ergoemacs-mode)
(setq ergoemacs-theme nil) ;; Uses Standard Ergoemacs keyboard theme
(setq ergoemacs-keyboard-layout "us") ;; Assumes QWERTY keyboard layout
(ergoemacs-mode 1)
(add-to-list 'load-path "~/.emacs.d/elpa/neotree-20150102.427")
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
;; Set bigger fonts
(set-default-font "Ubuntu Mono-16")
(add-hook 'clojure-mode-hook 'turn-on-eldoc-mode)
(setq nrepl-popup-stacktraces nil)
(add-to-list 'same-window-buffer-names "<em>nrepl</em>")
;; General Auto-Complete
(require 'auto-complete-config)
(setq ac-delay 0.0)
(setq ac-quick-help-delay 0.5)
(ac-config-default)
;; ac-nrepl (Auto-complete for the nREPL)
(require 'ac-nrepl)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-to-list 'ac-modes 'cider-mode)
(add-to-list 'ac-modes 'cider-repl-mode)
(add-hook 'clojure-mode-hook 'paredit-mode)
(global-set-key [f8] 'neotree-toggle)
;; Set bigger fonts
(set-default-font "Ubuntu Mono-16")
(add-hook 'clojure-mode-hook 'turn-on-eldoc-mode)
(setq nrepl-popup-stacktraces nil)
(add-to-list 'same-window-buffer-names "<em>nrepl</em>")
;; General Auto-Complete
(require 'auto-complete-config)
(setq ac-delay 0.0)
(setq ac-quick-help-delay 0.5)
(ac-config-default)
;; ac-nrepl (Auto-complete for the nREPL)
(require 'ac-nrepl)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-to-list 'ac-modes 'cider-mode)
(add-to-list 'ac-modes 'cider-repl-mode)
(add-hook 'clojure-mode-hook 'paredit-mode)
;; Show parenthesis mode
(show-paren-mode 1)
(custom-set-variables
;; 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.
'(custom-enabled-themes (quote (whiteboard)))
'(delete-selection-mode t)
'(org-CUA-compatible nil)
'(org-replace-disputed-keys nil)
'(recentf-mode t)
'(shift-select-mode nil))
(custom-set-faces
;; custom-set-faces 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.
)
I believe the shortcut you're looking for is M-.
https://github.com/clojure-emacs/cider#keyboard-shortcuts
Related
I am trying to install the clang-format automatic format tool, I have installed clang-format with M-x package-install clang-format
and I can see it in M-x list-packages.
My ~/.emacs is:
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl
(warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
;; clang-format
(require 'clang-format)
(global-set-key [C-M-tab] 'clang-format-region)
(add-hook 'c-mode-common-hook
(function (lambda ()
(add-hook 'write-contents-functions
(lambda() (progn (clang-format-buffer) nil))))))
(add-hook 'cpp-mode-common-hook
(function (lambda ()
(add-hook 'write-contents-functions
(lambda() (progn (clang-format-buffer) nil))))))
;; irony-mode
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
;; company mode
(add-hook 'c++-mode-hook 'company-mode)
(add-hook 'c-mode-hook 'company-mode)
;; flycheck-mode
(add-hook 'c++-mode-hook 'flycheck-mode)
(add-hook 'c-mode-hook 'flycheck-mode)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
;; eldoc-mode
(add-hook 'irony-mode-hook 'irony-eldoc)
(global-linum-mode)
(custom-set-variables
;; 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.
'(package-selected-packages
(quote
(list-packages-ext clang-format flycheck-clang-tidy flycheck-clang-analyzer elpy irony-eldoc company-irony flycheck-irony flycheck irony))))
(custom-set-faces
;; custom-set-faces was added by Custom.
'(linum ((t (:inherit (shadow default) :foreground "yellow")))))
But clang-format does not appear at the bottom of emacs window while Irony, FlyC, ElDoc and Abbrev appear.
Could anyone help me? Thank you!
From clang-format github instructions:
(require 'clang-format)
(global-set-key (kbd "C-c i") 'clang-format-region)
(global-set-key (kbd "C-c u") 'clang-format-buffer)
(setq clang-format-style-option "llvm")
It won't appear in the status line as it's not a minor mode.
You have to set key bindings to the function you want to use, like in the given example.
I have freshly installed auto-complete popup and ac-nrepl from elpa. When I enter a clojure buffer in emacs, the AC indicates auto-complete is turned on. But no matter what I type or do in the buffer, I cannot get autocomplete to do anything. I'v been troubleshooting this for awhile, any pointers? I have this in my emacs startup as well:
(add-to-list 'load-path "~/.emacs.d")
(require 'auto-complete-config)
(ac-config-default)
(package-initialize)
(require 'auto-complete)
(require 'ac-nrepl)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete" '(add-to-list 'ac-modes 'cider-repl-mode))
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-repl-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)
Try add cider-mode to ac-modes instead of cider-repl-mode:
(add-to-list 'ac-modes 'cider-mode)
I want to make the yasnippet as the backend of the auto-complete. However, it doesn't work. what I do after searched the internet is as follows:
get the auto-complete-yasnippet.el, add some elisp in the .emacs like this:
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
(yas-minor-mode nil)
(global-set-key (kbd "M-/") 'yas/expand)
;; Auto-complete settings
;; this is the code for the auto-complete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
;;setup for auto-complete-yasnippet
(require 'auto-complete-yasnippet)
(setq-default ac-sources
'(
;; ac-source-semantic
ac-source-yasnippet
ac-source-abbrev
ac-source-words-in-buffer
ac-source-words-in-all-buffer
;; ac-source-imenu
ac-source-files-in-current-dir
ac-source-filename
)
)
I look at the content in the ac-sources in *scratch* with C-h v, and it does have the ac-source-yasnippet. someone said that there may be something wrong with the version and upgrade of auto-complete as well as yasnippet. How can it be fixed?
My emacs version is 23.3.1 my auto-complete version is 1.3.1 and my yasnippet version is 0.8.0(beta) which is just downloaded from the github. any help?
you can easily do it by (require 'auto-complete-yasnippet)
and then you can change your auto-complete like follows:
(defun my-ac-config ()
(setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
;; (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
(add-hook 'css-mode-hook 'ac-css-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(add-hook 'octave-mode-hook 'ac-octave-mode-setup)
(global-auto-complete-mode t))
(defun my-ac-cc-mode-setup ()
(setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))
(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
;; ac-source-gtags
(my-ac-config)
It works fine on my machine.
there maybe something wrong with the auto-complete-config.el when acquire the ac-yasnippet-candidates in the auto-complete-1.3.1 version:
(defun ac-yasnippet-candidates ()
(with-no-warnings
(if (fboundp 'yas/get-snippet-tables)
;; >0.6.0
(apply 'append (mapcar 'ac-yasnippet-candidate-1 (yas/get-snippet-tables major-mode)))
(let ((table
(if (fboundp 'yas/snippet-table)
;; <0.6.0
(yas/snippet-table major-mode)
;; 0.6.0
(yas/current-snippet-table))))
(if table
(ac-yasnippet-candidate-1 table))))))
the code snippet above somewhat must be changed to be compatible with the yasnippet-0.8.0version. I download the newest version of auto-complete-1.4.0 from github and it solved the problem judge the version of yasnippet and take measures accordingly. Like this:
(defun ac-yasnippet-candidates ()
(with-no-warnings
(cond (;; 0.8 onwards
(fboundp 'yas-active-keys)
(all-completions ac-prefix (yas-active-keys)))
(;; >0.6.0
(fboundp 'yas/get-snippet-tables)
(apply 'append (mapcar 'ac-yasnippet-candidate-1
(condition-case nil
(yas/get-snippet-tables major-mode)
(wrong-number-of-arguments
(yas/get-snippet-tables))))))
(t
(let ((table
(if (fboundp 'yas/snippet-table)
;; <0.6.0
(yas/snippet-table major-mode)
;; 0.6.0
(yas/current-snippet-table))))
(if table
(ac-yasnippet-candidate-1 table)))))))
I copied the auto-complete-config.el from the auto-complete-1.4.0version, byte compiled it, and replaced the same files(both auto-complete-config.el and auto-complete-config.elc) in auto-complete-1.3.1version. it just worked! I think may the config file of auto-complete should not included in the distro and maybe it should maintained separately to make it easy to compatible with its backends.
I reconfigured the yasnippet and the auto-complete like this:
;; setup for yasnippet
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
;; Extension and configuration of yasnippet.
(require 'yasnippet-config)
;; If you use yasnippet from 'auto-complete', add
(yas/set-ac-modes)
(yas/enable-emacs-lisp-paren-hack)
;; before 'auto-complete' settings.
;; Auto-complete settings
;; this is the code for the auto-complete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
I use Emacs 24 from scratch with the latest yasnippet and auto-complete installed and nominally working. Now, as a emacs user and an android developer, I'd like to use my favorite editor and automate some tasks fr android development.
I know almost nothing about elisp.
My first task is to use custom snippets to add the uses-sdk tag in AndroidManifest.xml. That's ok with yasnippet but I'd like to use auto-complete to interactively propose and auto-complete android specific tags. The problem is that the major mode for AndroidManifest.xml is nxml and I don't want to propose android specifics to all nxml-mode related buffers. As a consequence, I use a condition on the buffer name in the snippet definition. Now, I'd like to add a custom hook to nxml-mode-hook but I failed to enable the auto-complete mode.
My snippet:
#contributor : Me, Myself and I
#name : <uses-sdk ... />
#condition : (string= (buffer-name) "AndroidManifest.xml")
# --
<uses-sdk android:minSdkVersion="$0" />
The .emacs part that miserably failed:
;; yasnippet
(add-to-list 'load-path "~/.emacs.d/yasnippet")
(require 'yasnippet)
(setq yas/trigger-key (kbd "C-c <kp-multiply>"))
(yas/initialize)
;; Develop in ~/emacs.d/mysnippets, but also
;; try out snippets in ~/Downloads/interesting-snippets
(setq yas/root-directory '("~/.emacs.d/snippets"
"~/.emacs.d/external-snippets"))
;; Map `yas/load-directory' to every element
(mapc 'yas/load-directory yas/root-directory)
;; auto-complete
(add-to-list 'load-path "~/.emacs.d/auto-complete")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/ac-dict")
(setq-default ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
(add-hook 'css-mode-hook 'ac-css-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(global-auto-complete-mode t)
;; android specific settings
;; AndroidManifest.xml
(defun ac-android-manifest-nxml-setup()
""
(when (string= (buffer-name) "AndroidManifest.xml")
(setq ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))))
(add-hook 'nxml-mode-hook 'ac-android-manifest-nxml-setup)
The snippet works as intended but the completion don't though the auto-completion works if I enable auto-complete using M-x auto-complete-mode.
Any help will be greatly appreciated.
Works well with
;; auto-complete
(add-to-list 'load-path "~/.emacs.d/auto-complete")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/ac-dict")
(ac-config-default)
;; android specific settings
;; AndroidManifest.xml
(defun ac-android-manifest-nxml-setup()
(when (string= (buffer-name) "AndroidManifest.xml")
(setq ac-sources '(ac-source-yasnippet
ac-source-abbrev
ac-source-dictionary
ac-source-words-in-same-mode-buffers))
((lambda () (auto-complete-mode 1)))))
(add-hook 'nxml-mode-hook 'ac-android-manifest-nxml-setup)
I'm using emacs with lisp (using slime) for a short time...this work but today when I run it appear this message:
eval-buffer: Symbol's function definition is void: define-slime-contrib
means this than my slime contrib folder is not found?
my .emacs is a disaster..sorry for this...I search inside all the folders and everyone look well...
;; SLIME ==================================================
'
;; Orden: M-x slime
(setq inferior-lisp-program "/usr/bin/clisp") ;
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
;;(require 'slime-autoloads)
(add-to-list 'load-path "/etc/emacs/site-start.d/") ;; I review all this folders and
(add-to-list 'load-path "/usr/lib/emacsen-common/packages/install/") ;; the address look good
(add-to-list 'load-path "/usr/share/doc/slime/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/contrib/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
(require 'slime)
(add-hook 'lisp-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))
(add-hook 'slime-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))
(add-hook 'html-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))
This is the relevant part of my .emacs:
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'load-path "~/.emacs.d/slime/")
(require 'slime)
(slime-setup)
When using it, I go to the Lisp buffer and run M-x slime and voila, it works.
Try changing your .emacs file from what you had to the following:
;; SLIME ==================================================
;; Orden: M-x slime
(setq inferior-lisp-program "/usr/bin/clisp")
(add-to-list 'load-path "/etc/emacs/site-start.d/") ;; I review all this folders and
(add-to-list 'load-path "/usr/lib/emacsen-common/packages/install/") ;; the address look good
(add-to-list 'load-path "/usr/share/emacs/site-lisp/")
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
(require 'slime)
(slime-setup)
(add-hook 'lisp-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))
(add-hook 'slime-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))
(add-hook 'html-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'newline-and-indent)))