company-clang always No completion found - emacs

i have post and issue on company-mode's git site, but i cant't draw any attention there, maybe author is in some kind of busy recently. so i post here now.
when i setup the company, and want to use it.
there are always:
No completion found
user-error: Cannot complete at point
here is my init setup:
(require 'cc-mode)
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(setq company-backends (delete 'company-semantic company-backends))
(define-key c-mode-map [(tab)] 'company-complete)
(define-key c++-mode-map [(tab)] 'company-complete)
(setq company-clang-executable "/usr/bin/clang-3.8")
and i also found, when i want to exit the emacs, i found compay-clang still running(have a active buffer, shown in process list):
company-clang run *clang-output* /dev/pty1 /usr/bin/clang-3.8 -fsyntax-only -Xclang -code-completion-macros -x c++ -I/cygdrive/e/lua/include -I/usr/include -Xclang -code-completion-at=-:28:5 -
btw, i use this setup(almost the same, such as include path) for auto-complete-clang, and it works fine.
i seems that company-clang have been running into a loop, because when i try to close the clang-output buffer, it always left a message which is "Buffer "clang-output" has a running process; kill it? (yes or no) ".
but the more important is that there is nothing in that buffer.

Use pipes instead of PTYs to receive output from Clang

Related

Unable to run emacs in `magit-status-mode` with using custom initialization file

I like to use terminal tools and the one of them is 'magit' - awesome Git client implemented as an Emacs package. I use it to control Git projects. I have a script which automatically start emacs at computer boot (this same me a time with routine work). But also I'm looking for a way to run emacs in magit-status mode (without manual executing M-x magit-status... each time). Emacs provide a possibility to configure it's environment in init configuration file. To make emacs run magit at boot I created special magit.el file and run emacs from command line
$ emacs -q --load ~/.emacs.d/magit.el
Unfortunately I unable to switch emacs in magic-status-mode - something wrong with init file. Emacs remains in lisp-interaction-mode after boot. The content of init file is below:
;; disable welcome screen at launch
(setq inhibit-startup-screen t)
(setq visible-bell t)
; Disable tabs indent
(setq-default c-basic-offset 4
tab-width 4
indent-tabs-mode nil)
(global-set-key "\C-h" 'delete-backward-char)
;; Makes *scratch* empty.
(setq initial-scratch-message "")
;; Removes *scratch* from buffer after the mode has been set.
(defun remove-scratch-buffer ()
(if (get-buffer "*scratch*")
(kill-buffer "*scratch*")))
;(add-hook 'after-change-major-mode-hook 'remove-scratch-buffer)
;; Removes *messages* from the buffer.
;(setq-default message-log-max nil)
;(kill-buffer "*Messages*")
;; Removes *Completions* from buffer after you've opened a file.
;(add-hook 'minibuffer-exit-hook
; '(lambda ()
; (let ((buffer "*Completions*"))
; (and (get-buffer buffer)
; (kill-buffer buffer)))))
;; Don't show *Buffer list* when opening multiple files at the same time.
(setq inhibit-startup-buffer-menu t)
;; Show only one active window when opening multiple files at the same time.
;(add-hook 'window-setup-hook 'delete-other-windows)
;; Tell emacs where is your personal elisp lib dir (magit)
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "git") ;; best not to include the ending “.el” or “.elc”
;; activate installed packages
(package-initialize)
(setq-default major-mode 'magit-status-mode)
(add-hook 'after-init-hook #'magit-status-mode)
(if after-init-time
(add-hook 'after-init-hook #'magit-status-mode))
Try this:
(call-interactively 'magit-status)
Instead of all of this:
(setq-default major-mode 'magit-status-mode)
(add-hook 'after-init-hook #'magit-status-mode)
(if after-init-time
(add-hook 'after-init-hook #'magit-status-mode))
Using after-init-hook would make sense in an init file, but with -q you're explicitly not using an init file (using --load is not the same thing), and that hook has already run by the time your custom magit.el file is loaded, so nothing you add to the hook at that stage will ever be processed.
Note that you don't want to call magit-status-mode at all. That's not a major mode you would ever be expected to invoke manually, as you would never want that mode for any buffer other than the one created by the magit-status command.

Emacs Auctex compile error: "Use M-x make-directory RET RET to create the directory and its parents"

I am running emacs 23.3.1 on ubuntu 12.04 with auctex 11.86. Whenever I go to compile a latex document (using C-c C-c), if there are no errors, everything compiles just fine. However, if there are any errors it will tell me to use C-` to view errors, if I do so, I get this error message
Use M-x make-directory RET RET to create the directory and its parents
and it goes away after a couple seconds. Then it takes me to another screen that explains the error in the latex code. However, now I cannot simply do C-x 1 to get back to the latex code. I have to C-x C-c and restart emacs.
This is my .emacs file
(setq backup-by-copying t
backup-directory-alist '(("." . "~/.emacsBkups"))
delete-old-versions t
kept-new-versions 5
kept-old-versions 2
version-control t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
;;(require 'ess-site)
;;(ess-toggle-underscore nil)
(require 'whitespace)
(setq whitespace-style '(lines-tail face))
(add-hook 'c-mode-hook 'whitespace-mode)
(add-hook 'c++-mode-hook 'whitespace-mode)
(add-hook 'python-mode-hook 'whitespace-mode)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(c-set-offset (quote cpp-macro) 0 nil)
(setq TeX-view-program-list '(("Evince" "evince --page-index=%(outpage) %o")))
(setq TeX-view-program-selection '((output-pdf "Evince")))
Sometimes AUCTeX gets confused parsing the log of (La)TeX compilation and isn't able to guess the correct line raising the error. In some cases AUCTeX issues an obscure message "Error occured after last TeX file closed", when there are unbalanced parentheses, in your case it suggests you to create a new directory. To help AUCTeX finding the correct line raising the error you can add the -file-line-error option to latex or pdflatex by customizing the variable LaTeX-command-style. To do this add the following code to your .emacs:
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -file-line-error %S%(PDFout)")))
See also the AUCTeX FAQ:
8. Why does TeX-next-error (C-c `) fail?
When writing the log file, TeX puts information related to a file,
including error messages, between a pair of parentheses. AUCTeX
determines the file where the error happened by parsing the log file
and counting the parentheses. This can fail when there are other,
unbalanced parentheses present.
As a workaround you can activate so-called file:line:error messages
for the log file. (Those are are easier to parse, but may lack some
details.) Either you do this in the configuration of your TeX system
(consult its manual to see where this is) or you add a command line
switch to the (la)tex call, e.g. by customizing LaTeX-command-style or
TeX-command-list.

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: disable Ido completion in Tramp mode

I often use ido for auto-completion and tramp to access remote server via ssh. My .emacs includes the following lines:
(require 'tramp)
(setq tramp-default-method "ssh")
(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
I want to disable Ido completion, when i'm browsing contents of remote server. Note that variable ido-enable-tramp-completion has nothing to do with my problem. Consider line /root#site.com#1234:/var/www/file.txt. I need Ido not to deduct the part after the colon (remote file path), i don't care about the part before the colon. I use ssh, and Ido makes Emacs lag for a few seconds every time i run ido-find-file, and when ssh timeout is over, Tramp tries to reconnect, asks me for a password and so on. This behavior is undesirable.
Emacs version - 24.0.94.1
Edit (20.03.12): After contact with Ido author I tried to change the ido-file-name-all-completions-1 to the following:
(defun ido-file-name-all-completions-1 (dir)
(cond
((ido-nonreadable-directory-p dir) '())
;; do not check (ido-directory-too-big-p dir) here.
;; Caller must have done that if necessary.
((and ido-enable-tramp-completion
(or (fboundp 'tramp-completion-mode-p)
(require 'tramp nil t))
(string-match "\\`/[^/]+[:#]\\'" dir))
;; TRAMP RELATED CODE DELETED
nil)
(t
(file-name-all-completions "" dir))))
No success. I then changed regex to
"\\`/[^/]+[:#]"
and it worked - Ido was disabled, when minibuffer contained that match. However as Ido couldn't see files on a remote server, it started calling ido-make-merged-file-list to search for files in other directories every time i enter something. This made working with Ido on remote servers even more pain.
I also tried setting up variables ido-slow-ftp-hosts and ido-slow-ftp-host-regexps to /root#site.com#1234, didn't help.
If you enter C-x C-f again you temporally disable ido-find and fall back to the default find-file.
For more information C-h f ido-find-file RET
To do this every time ido found a colon, I guess you have to write your own function for that.

eval-buffer doesn't do anything when setting up CLISP/SLIME

I am using the following tutorial:
http://www.pchristensen.com/blog/articles/installing-clisp-emacs-and-slime-on-windows-xp/
I have set-up all the directories and downloaded all the necessary files. However, on step 4. I am using the emacs command "eval-buffer". I type in my settings, ran "eval-buffer", received feedback (in the bottom bar), and assumed everything worked correctly. Then when I ran M-x "slime" I received the error:
Spawning child process: invalid argument
I assumed I had typed something incorrectly in my .emacs file so I re-edited it. However, now when I attempt to run M-x "eval-buffer" I receive no feedback and I don't believe my new code executes.
My file, by the way, is:
(setq inferior-lisp-program "C:/Documents and Settings/U9UW/Desktop/root/bin/clisp/full/lisp.exe -B C:/Documents and Settings/U9UW/Desktop/root/bin/clisp/full -M
C:/Documents and Settings/U9UW/Desktop/root/bin/clisp/full/lispinit.mem -ansi -q")
(add-to-list 'load-path "C:/Documents and Settings/U9UW/Desktop/root/bin/emacs/site-lisp/slime/")
(require 'slime)
(slime-setup)
eval-buffer actually was evaluating. To fix the problem "Spawning child process: invalid argument", one has to replace the first line with:
(setq inferior-lisp-program “clisp”)