emacs scratch not interactive mode - emacs

I updated a lot of packages that I had directly from github to the MELPA packages. Nonetheless something really weird happened to my *scratch* buffer. The default message is not appearing (the buffer is completely empty), and also the interactive elisp mode is not set (let's say I write (+ 2 2) and then hit C-j and it tells me invalid function). I have no idea why. I don't even know how to debug it to check where the error is. Any ideas?

Finally the problem was generated by flycheck-add-next-checker, for some reason, using the MELPA repositories is generating this error. I just commented the following part of my configuration file.
(eval-after-load 'flycheck
'(progn
;; Add Google C++ Style checker.
;; In default, syntax checked by Clang and Cppcheck.
(flycheck-add-next-checker 'c/c++-clang
'(warnings-only . c/c++-googlelint))))

Related

Emacs: auto-complete-mode on but no auto-suggestions showing (Emacs lisp mode)

I'm puzzled as to why nothing pops up (in Emacs lisp mode) when I begin typing a function name. For example, after typing (def on a new line, I would assume that auto-complete should be showing me a alist of options which includes defun. Am not sure how long the default delay is, but I waited for a few seconds and nothing happened. Any suggestions?
Details regarding my installation process:
Installed using package-install via Melpa
Added the following two lines to my init.el file:
(require 'auto-complete-config)
(ac-config-default)
Confirmed that load-path includes the folder containing the .el files associated with auto-complete. (I have it set-up to recursively add all folders under path/to/my/.emacs.d/.)
Confirmed (via describe-variable) that ac-dictionary-directories includes the correct directories when Emacs starts up. As reference, it includes the following two directories:
ac-dictionary-directories is a variable defined in 'auto-complete.el'.
Its value is ("/home/dchaudh/Dropbox/dchaudhUbuntu/emacs/.emacs.d/elpa/auto-complete-20140824.1658/dict")
Confirmed that auto-complete-mode is on when I open my init.el file, which obviously triggers emacs-lisp-mode (I can see Emacs Lisp in my mode line). The following is included in the summary of active modes (i.e., via describe-mode):
Global-Auto-Complete minor mode (no indicator)
Toggle Auto-Complete mode in all buffers.
With prefix ARG, enable Global-Auto-Complete mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Not a direct answer, but company works fine out of the box in emacs-lisp-mode, so you might want to try that one.
In my experience, other modes (e.g. flyspell) can interfere with auto-complete operation. (There is a workaround for slyspell built into auto-complete but you have to activate it in your. emacs file.)
I'd suggest trying it with an empty. emacs and then gradually adding parts of your configuration back in. You should be able to find the problem that way.

emacs doremi: to change color-themes

I'm trying to get doremi working in emacs. Specifically, at this stage, to allow me to quickly scroll through a condensed list of color-themes and see each theme as I go through it. For this I would use the 'M-x doremi-color-themes+' command.
What I've done:
Installed color-themes (successfull)
Installed doremi.el, doremi-cmd.el, ring+.el and added
(add-to-list 'loadpath "~/elisp/themes")
(add-to-list 'loadpath "~/elisp/doremi/")
(require 'color-theme)
(color-theme-initialize)
(color-theme-classic)
;; create a list of color themes to scroll through using 'doremi-cmd
(setq my-color-themes (list 'color-theme-classic
'color-theme-retro-green
'color-theme-gray30
'color-theme-subtle-hacker
'color-theme-jonadabian-slate))
(require 'doremi)
(require 'doremi-cmd)
(require 'ring+)
to the .emacs file.
What emacs does:
When I type the comand 'M-x doremi-color-themes+' into the mini-buffer it seems to accept that I've given it a valid command and tells me to use the and arrow keys to move through the list. But when I do that all that happens is the cursor moves up and down in the active window. No changing of color-themes.
Being somewhat new to emacs (and especially customising it) I'm sure I have missed a step or put something in the wrong place. Perhaps there's some sort of (setq 'bla-bla-bla (...)) I need to do?
Sorry for your trouble. Please state your Emacs version (M-x emacs-version), and your version of color-theme.el.
You do not need to require library ring+.el if you use Emacs 23 or later (its code was included in GnuEmacs 23.)
You do not need to use (color-theme-initialize) or (color-theme-classic). The former is done automatically by doremi-color-themes+.
Try starting from emacs -Q (i.e., no init file, ~/.emacs), to be sure there is no interference from stuff in your init file.
Your variable my-color-themes is not referenced anywhere. Instead of defining that variable, just customize user option doremi-color-themes. (Or leave its value nil, which means that all color themes will be cycled through.)
Feel free to contact me by email if you continue to have a problem. Or continue here, if you prefer.
[Just to be sure: you are using color-theme.el, right? There is a lot of confusion out there between Emacs "custom themes" and color themes. Do Re Mi supports both, but they are different critters.]
After a bit for back and forth with #Drew we found a solution to the problem.
It turned out the major problem was that I was using emacs in 'terminal mode' rather than as a GUI application. Bare in mind I'm using a mac.
In the context of Terminal, my arrow keys send escape sequences and so doremi cannot read the event as intended. So it just escapes and applies the message to the active buffer.
There is an answer.
By adding the following lines to my .emacs file (or whatever your init file for emacs is) I was able to redirect doremi to use two other keys. ie. not the up and down arrows.
(setq doremi-down-keys '(?n))
(setq doremi-up-keys '(?p))
Doing this tells doremi to use 'n' as the down key and 'p' as the up key. And all works just fine.
Because I am only new to the world of programming and computing I may often use incorrect terminology. If this is the case please let me know and I will edit accordingly for clarity and consistency.

ac-auto-start (auto-complete mode) would not get set no matter what

I'm facing a very bizarre behaviour. No matter how I set ac-auto-start, be it through customization, by evaluating (setq ac-auto-start 2), (setq-default ac-auto-start 2) or (setq-local ac-auto-start 2) immediately after I do it, the variable is set to nil.
I've looked through the source of auto-complete mode and the ac-slime in my case, but none of these does nothing to this variable. I am at a loss as to how to deal with this.
The effective consequences of this malfunction is that completion combobox doesn't appear on its own, unless I force it to by doing M-x auto-complete. This behaviour is consistent in all modes where auto-complete minor mode is enabled.
EDIT
This seems to be an issue with latest Emacs. Now it fails to modify variables values, no matter what variable it is. So, say, after running it with -Q I've now discovered that I can't evaluate the code that uses (setq ...) forms as it has no effect. :/ So, please, hold on, I'll try to investigate this...
This was due to the typo, but the original problem is still there.
Emacs version is 24.3.50.1 pulled from trunk about a week ago.
auto-complete is version 1.4 installed from MELPA.
I'm setting the variable by moving the point to the REPL buffer, then M-:. I check its value in the same way.
EDIT2
OK, I finally found the reason: I had enzyme package installed, and it had an earlier version of auto-complete inside of it, for some reason parts of the auto-complete code were loaded from there and other parts from the one installed from MELPA. After disabling enzyme it all works well now.
EDIT3
This still happens after I run (auto-complete-mode 1) in the REPL buffer. The variable will become impossible to set. I've searched through various autocomplete timers that may be setting something, but no luck so far.
There is indeed something strange going on with the setting of auto-complete-mode.
(I'm using the ELPA version in a GNU Emacs 24.3.1)
This is set up by customize-group RET auto-complete :
'(ac-auto-show-menu t)
'(ac-auto-start t)
At this point if you M-x auto-complete-mode you get a [no match] right in the minibuffer. Only after you try to M-x auto-complete, yelding a "auto-complete-mode is not enabled" weird error, will you be able to M-x auto-complete-mode (but without command completion... Hm) and then be in the mode.
If you put this in your init file (.emacs)
(require 'auto-complete)
(auto-complete-mode t)
It will be effective only if you re-eval it after startup (?!?).
The same with something like
(if (auto-complete)
(auto-complete-mode t))
The only way that I found to get auto-complete-mode to load at startup is to :
(eval-and-compile
(require 'auto-complete nil 'noerror))
(The above customize options are now effective)

Emacs desktop-save-mode startup error

After adding the following code in my .emacs file, comes up some error during startup of emacs. I am a newbie of emacs, is there some one can help me figure out where are the errors come from?
Added code in .emacs:
;; Auto-saving the Desktop
(require 'desktop)
(desktop-save-mode 1)
(defun my-desktop-save ()
(interactive)
;; Don't call desktop-save-in-desktop-dir, as it prints a message.
(if (eq (desktop-owner) (emacs-pid))
(desktop-save desktop-dirname)))
(add-hook 'auto-save-hook 'my-desktop-save)
Errors:
Looking at the function definition for what's breaking, it seems that the error is that prj-file is NIL in line 492. (The other expand-filename call in the function shouldn't ever have a nil, since it's the car of a non-nil list of filenames).
Now, prj-file is the first filename in /home/shenyan/Test/memcached-1.4.11 matching the regexp "\\(Root\\)?ProjStep.ede" and presumably there isn't one. Since memcached presumably doesn't have an EDE project file, what's gone wrong must be that line 508's call to ede-project-p did something weird when called with this subdirectory of /home/shenyan/Test/.
I can't work out exactly why that happened, but you can debug things quite easily. First bring up your *scratch* buffer to type emacs lisp easily. To check my guess, insert the following code into the buffer
(ede-directory-project-p "/home/shenyan/Test/memcached-1.4.11")
and run it by hitting C-x C-e with cursor on the closing bracket. If it returns nil I was wrong. Otherwise, you've found the culprit and should probably debug it further by hunting through the bits of ede-directory-project-p in ede-files.el.
Probably what's going on is that your /home/shenyan/Test/ directory has something that tells EDE to search subdirectories (or maybe that's the default?) and then the memcached subdirectory has a file whose name makes EDE think it should be searched for a project file. If you work out exactly what happened, you might consider submitting a bug to the EDE developers: they probably shouldn't error out if the project file doesn't exist.

Entering a minor mode with a major mode in Emacs

This question may be a duplicate of this question, but I can't get the following to work properly in my emacs.
I am trying to enter minor mode mlint-mode whenever I enter major mode matlab-mode (both modes available at their SourceForge page). I have the following in my .emacs file:
(add-hook 'matlab-mode-hook
(function (lambda()
(mlint-mode))))
which looks like the answer to the question I linked above. When opening a .m file, I get the following error:
File mode specification error: (void-function mlint-mode)
Could someone please assist in helping me write the correct hook to enter mlint-mode when I open a .m file? FWIW, I'm running emacs 23.1.50.1.
I think the correct name is mlint-minor-mode. Also, remember to ensure that all matlab stuff is known by Emacs, this can be done using:
(require 'matlab-load)
As a side note, it is typically a bad idea to use lambda functions in hooks. If you inspect the value of the hook you will see a lot of unrelated things. Also, if you modify your lambda expression and re-add it, both the old and the new version will be on the hook.
Instead, you can do something like:
(defun my-matlab-hook ()
(mlint-minor-mode 1))
(add-hook 'matlab-mode-hook 'my-matlab-hook)
The "1" is ensures that mlint mode is turned on or stay on if enabled earlier.