ac-math error in emacs - emacs

I installed ac-math plugin as well as auto-complete. I ac-math.el in .emacs.d/plugins/auto-complete
I put this in my .emacs
(add-to-list 'load-path "~/.emacs.d/plugins/auto-complete/.")
(add-to-list 'ac-dictionary-directories "~/.emacs.d/plugins/auto-complete/ac-dict/")
(require 'auto-complete-config)
(ac-config-default)
(require 'ac-math)
(add-to-list 'ac-modes 'latex-mode) ; make auto-complete aware of latex-mode
(defun ac-latex-mode-setup () ; add ac-sources to default ac-sources
(setq ac-sources
(append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands)
ac-sources)))
(add-hook 'latex-mode-hook 'ac-latex-mode-setup)
But I get the error "wrong type argument: integrep nil". Any help?

As far as auto-complete-mode is concerned there is a rather out-dated homepage: http://cx4a.org/software/auto-complete/
If you install from there you propably do not have an up to date version like eg the one that can be found on github ( https://github.com/auto-complete/auto-complete ). In that repository the branch for version 1.3 (the one that is available on the homepage) was not updated in the last three years.

Related

Latest ada-mode (5.1.9) does not indent on Emacs for OS X (24.5.1)

I recently upgraded from the ada-mode built-in to Emacs for the updated elpa version (5.1.9) due to issues with compiling from within ada-mode with the earlier version (4.0.0).
In the updated package it is impossible to indent, with TAB performing no operation at all except to move all text on all lines to the leftmost column, regardless of whether it should be indented or not. No other type of indenting (ada-indent-current, ada-indent-region, or ada-indent-newline-indent) work either and neither does automatic indentation via RET.
There is no mention in *Messages* that there is any problem, and the built-in version has no trouble with the indentation.
I'm quite new to Emacs, but I've been trying to solve this problem for a while now with no solution in sight.
My init.el is below in case I've simply done something strange in my noviceness:
(package-initialize)
;; (setq package-enable-at-startup nil)
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(add-to-list 'load-path "~/.emacs.d/lisp")
(global-linum-mode t) ;; Show line numbers
(autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(when (eq system-type 'darwin) ;; mac specific settings
(setq mac-option-modifier 'meta))
(setq exec-path-from-shell-check-startup nil)
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))
(ac-config-default)

How to make the yasnippet as the auto-complete backend?

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)

swank-clojure and slime no longer co-operating in emacs

I made the mistake of updating my existing ports with MacPorts -- now slime and swank-clojure no longer work. I get the following message when I invoke clojure-jack-in within emacs:
Versions differ: 2011-04-16 (slime) vs. 20100404 (swank). Continue? (y or n)
Entering y will bring up the slime REPL, but then when I try to evaluate an expression in the REPL, I get another message:
Not connected. Use `M-x slime' to start a Lisp.
What is going on here?
Here are the relevant portions of my init.el file:
;; slime
(setq inferior-lisp-program "/opt/local/bin/sbcl")
(add-to-list 'load-path
"/opt/local/share/emacs/site-lisp/slime"
"/opt/local/share/emacs/site-lisp/slime/contrib")
(add-hook 'slime-repl-mode-hook
(defun clojure-mode-slime-font-lock()
(require 'clojure-mode)
(let (font-lock-mode)
(clojure-mode-font-lock-setup))))
(require 'slime)
(slime-setup '(slime-repl))
(eval-after-load "slime" '(slime-setup '(slime-fancy slime-banner)))
;; clojure
(add-to-list 'load-path
"~/.emacs.d/elpa/clojure-mode-el"
"~/.emacs.d/elpa/paredit-22")
(require 'clojure-mode)
(defun turn-on-paredit () (paredit-mode 1))
(add-hook 'clojure-mode-hook 'turn-on-paredit)
swank-clojure only works with slime version 20100404:
https://github.com/technomancy/swank-clojure/issues/120#issuecomment-4862556
only option at this point is to downgrade version of slime.

Adding Marmalade as Package Source

I'm trying to add Marmalade as a package source, but when I do so I get the error:Symbol's value as variable is void: package-archives. Anyone know how to resolve this? Below is my .emacs file.
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
(add-to-list 'load-path (expand-file-name "~/.emacs.d"))
(add-to-list 'load-path "~/.emacs.d/plugins")
(add-to-list 'load-path "~/.emacs.d/plugins/color-theme")
(add-to-list 'load-path "~/.emacs.d/plugins/groovy")
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
To install package.el
I ran the following code:
(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))
Use the package.el to be included with emacs24, as the ELPA version doesn't include package-archives and support for multiple repositories.
It is found here (emacs24!): http://bzr.savannah.gnu.org/lh/emacs/trunk/annotate/head:/lisp/emacs-lisp/package.el
Last emacs23 compatible version: http://repo.or.cz/w/emacs.git/blob/ba08b24186711eaeb3748f3d1f23e2c2d9ed0d09:/lisp/emacs-lisp/package.el
Drop it into your loadpath and settle for one type of loading (that is drop the lines after the comment).

Make auto-complete and yasnippet modes work together to edit a specific file in GNU/Emacs

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)