Why Emacs project C-c p is undefined? - emacs

I am new to Emacs. I have installed Projectile.
When I do C-c p, it says:
C-c p is undefined
Wondering what is wrong?
Following is my ~/.emacs file.
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(defvar required-packages
'(
projectile
) "a list of packages to ensure are installed at launch.")
(require 'cl)
; method to check if all packages are installed
(defun packages-installed-p ()
(loop for p in required-packages
when (not (package-installed-p p)) do (return nil)
finally (return t)))
; if not all packages are installed, check one by one and install the missing ones.
(unless (packages-installed-p)
; check for new packages (package versions)
(message "%s" "Emacs is now refreshing its package database...")
(package-refresh-contents)
(message "%s" " done.")
; install the missing packages
(dolist (p required-packages)
(when (not (package-installed-p p))
(package-install p))))
(require 'projectile)
(projectile-global-mode)
Edit
My .projectile file
-/venv
-*.pyc
-*.pyc~
-.git
-.gitignore
-.DS_Store
Edit 2
C-h v output for projectile-keymap-prefix as below:
projectile-keymap-prefix is a variable defined in `projectile.el'.
Its value is "^Cp"
Documentation:
Projectile keymap prefix.
You can customize this variable
Edit 3
I am using OS X 10.10.4. I start emacs from command line $emacs. I have installed Emacs using following commands:
brew install emacs --with-cocoa
And, very first time (when I launch emacs). If do M-x, I don't get project-switch-project, rather I get project-switch-to-buffer. After switching buffer, I can switch project.

You now need to explicitly enable it and set a prefix. The steps to enable Projectile with a C-c C-p prefix:
(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)
This has changed a couple times in 2018. Boris used to set C-c p as the default leader, then changed it to C-c C-p to be in accordance with the emacs keybinding conventions (bullet #2 mentions it.). But now it's removed altogether, so you should set it yourself.

You need to manually activate projectile mode in your ~/.emacs file:
(projectile-mode 1)

Projectile's default keymap prefix is defined by the variable projectile-keymap-prefix. You can use C-h v to see value of that variable. If not set or is not ^Cp, you can use the code below to set it to C-c p
(setq projectile-keymap-prefix (kbd "C-c p"))
or any else key binds as you like.

I encountered a similar problem recently that projectile-global-mode doesn't work as how it worked before after I had pinned the projectile package to the melpa stable archive, which was of the version v0.14.0.
The way that projectile-global-mode behaved before is that when turned on the keybindings are available from any buffer, but now I can't get it to work when in the splash screen (which is in Fundamental mode) after emacs starts, like Menno Smits points out in the comment.
For the sake of curiosity, I git bisect the source code history of projectile to find out which commit introduces this behavior change and finally get this, which no longer uses define-globalized-minor-mode to define the global minor mode but defines the projectile-mode as global by default with (define-minor-mode xxxxxx :global t), the difference could be told from the doc of define-globalized-minor-mode I think:
Globally enabling the mode also affects buffers subsequently created by visiting files, and buffers that use a major mode other than Fundamental mode; but it does not detect the creation of a new buffer in Fundamental mode. Source
Not sure if this relates, but this's how I figured it out and hope it helps anyone having the same confusion as mine.

Related

C-c C-c does not work anymore to compile a tex under Emacs

I just upgraded my Ubuntu from 12.04 to 14.04.
When I edited .tex file under 12.04, I have set up my Emacs in such a way that C-c C-c launched automatically Latex, View or BibTex according to the circumstance. Consequently, I just needed to keep pressing C-c C-c to compile and view a simple .tex file. A part of the ~/.emacs file is as follows:
(require 'server)
(or (server-running-p)
(server-start))
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
(defun pdf-with-okular ()
(add-to-list 'TeX-output-view-style
(quote ("^pdf$" "." "okular %o %(outpage)"))))
(add-hook 'LaTeX-mode-hook 'pdf-with-okular t)
(setq TeX-view-program-list '(("Okular" "okular %o")))
(setq TeX-view-program-selection '((output-pdf "Okular") (output-dvi "Okular")))
(eval-after-load "tex"
'(setcdr (assoc "LaTeX" TeX-command-list)
'("%`%l%(mode) -shell-escape%' %t"
TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")))
(custom-set-variables
'(LaTeX-command "latex -synctex=1")
'(cua-mode t nil (cua-base))
'(show-paren-mode t)
'(tool-bar-mode nil))
After upgrading, this mechanism does not work anymore: C-c C-c launches Command [pdflatex], and if I just press Enter, it could not find the .tex file.
Does anyone know what is wrong?
It sounds like the command you expect to be bound to C-c C-c is not -- some other command is.
C-h m tells you what mode you are in, and some things about it. C-h k C-c C-c tells you what command is bound to C-c C-c, and it gives you a link to the library where that command is defined.
This info, together with your init file and the Lisp source code, will help you find out why C-c C-c is not bound to the command you expect.
And you might want to start your search by bisecting your init file, to narrow it down to the code that causes the problem.
In sum, the answer is to ask Emacs first.
The command that you describe comes from the AUCTeX extension, which replaces the built-in LaTeX mode of Emacs. It appears that AUCTeX was not properly upgraded or removed from your system, so you are back to the built-in mode, which is pretty primitive compared to AUCTeX.
Check whether AUCTeX is still available in your Emacs session (e.g. M-x locate-library RET auctex). Also, check whether the AUCTeX package is still installed, and reinstall it if necessary.
Alternatively, you can obtain AUCTeX from GNU ELPA with Emacs' built-in package manager, which makes your Emacs setup independent from your system.

Emacs: can't autostart projectile installed through MELPA

I'm fairly new to emacs. In fact I'm learning the editor and trying to setup something that will replicate "go to a file inside the project" feature known from Code::Blocks or certain plugins of notepad++.
'projectile' fulfills this need, and I installed it through MELPA. Package installed properly, as I can start it with M-x projectile-global-mode and C-c p commands are recognized.
However, if I put it into my .emacs file, Emacs starts with an error:
Symbol's function definition is void: projectile-global-mode
Contents of my .emacs file are as follows:
(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-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.
)
(global-whitespace-mode 1)
(global-linum-mode 1)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(projectile-global-mode 1)
When I try to (require 'projectile) first, I only end up with another error:
'File error: Cannot open load file, projectile'
I'm using Emacs 24.3.1.
How do I put this on autostart properly?
By default, Emacs initializes packages after evaluated init.el. Hence, in a standard setup, packages are not yet available while init is evaluated.
Use (add-hook 'after-init-hook #'projectile-global-mode) to enable Projectile only after packages are initialized, or explicitly initialize packages at the beginning of your init.el with the following code:
(require 'package)
(setq package-enable-at-startup nil) ; To avoid initializing twice
(package-initialize)
You have to load projectile first, e.g. by using this:
(require 'projectile)
(projectile-global-mode)
you can add
'(initial-major-mode (quote projectile-global-mode))
to your .emacs(or init.el or whatever your file is called) file in the custom-set-variable section.
Alternatively, in newer versions of emacs, the menu Options | Customize Emacs | Specific Option you can type 'initial-major-mode' and this will take you to an interface where emacs can customize itself with that setting. just remember to apply and save

can't find any symbol in common lisp in emacs with slime

According to the guide on the Internet, we can search in the HyperSpec for the symbol like "format" in emacs by typing C-c C-d h , However, I just cannot have it work, emacs just prompts that there's no completion for the symbol. Can somebody cope with it? thanks in advance!
Are you actually using the Slime REPL mode? Sometimes, when starting Slime without any configuration, you're not getting the REPL mode, and instead you'll be sitting in the *inferior-lisp* buffer.
First of all, check what the title of the buffer is. If it's *inferior-lisp*, it's not the correct one. It should read *slime-repl sbcl* (where sbcl refers to the CL implementation you're using).
If this is the case, then you need to make sure you enable slime-fancy in your Emacs init file. This is what I have:
(defun init-slime-configuration ()
(slime-setup '(slime-fancy slime-fuzzy))
(setq slime-load-failed-fasl 'never)
(define-key slime-repl-mode-map (kbd "C-<tab>") 'slime-fuzzy-complete-symbol)
(define-key slime-mode-map (kbd "C-<tab>") 'slime-fuzzy-complete-symbol))
(add-hook 'slime-load-hook 'init-slime-configuration)
This also allows me to use C-TAB for fuzzy expand.
I ran into this very problem after switching from the version of SLIME installed using Quicklisp (version 2.9) to that installed from MELPA (version 20141010.1357, as a dependency of ac-slime).
Using SLIME from Quicklisp worked fine with my local copy of the HyperSpec, using the settings:
(require 'slime-autoloads)
(add-to-list 'slime-contribs 'slime-fancy)
(setq slime-lisp-implementations
'((ccl ("ccl"))
(clisp ("clisp"))
(cmucl ("cmucl"))
(ecl ("ecl"))
(sbcl ("sbcl"))))
(setq slime-default-lisp 'sbcl)
(setq common-lisp-hyperspec-root "file:/usr/share/doc/HyperSpec/")
(setq common-lisp-hyperspec-symbol-table "file:/usr/share/doc/HyperSpec/Data/Map_Sym.txt")
I then completely removed and reinstalled Quicklisp (without reinstalling SLIME!), then installed ac-slime from MELPA using the Emacs package manager.
By chance I happened to notice that when I tried to lookup documentation in the HyperSpec, Emacs opened a hidden buffer with an empty file named "Map_Sym.txt" in it.
Looking at the full pathname of this file using C-h v buffer-file-name [RET] revealed that it was set to "/home/miki/file:/usr/share/doc/HyperSpec/Data/Map_Sym.txt".
As an experiment, I tried removing the "file:/" from the last two lines of my settings, to make them read:
(setq common-lisp-hyperspec-root "/usr/share/doc/HyperSpec/")
(setq common-lisp-hyperspec-symbol-table "/usr/share/doc/HyperSpec/Data/Map_Sym.txt")
It appears to have resolved the issue. Why this works, I don't know (it differs from the documentation). A bug or undocumented change, maybe?

Symbol's function definition is void: x-cut-buffer-or-selection-value

Just installed Emacs 24 under Windows 7
Getting the following error when trying to cut & paste (kill & yank) within emacs, e.g.
C-k, C-y
to kill a line and copy it somewhere else:
Symbol's function definition is void: x-cut-buffer-or-selection-value
I have commented out the following from my .emacs and restarted emacs but error remains:
;; get copy and paste to work between emacs and other windows
;; (setq x-select-enable-clipboard t)
;; (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
I have no similar problems using emacs 24 with the same .emacs file under linux
I have done an initial googel trawl but all the information I found suggest the bug has been fixed already which isn't much help
Unfortunately, this is making emacs unusable under windows for me
UPDATE
this line doesn't seem to be causing the problem:
;; get copy and paste to work between emacs and other windows
(setq x-select-enable-clipboard t)
however these lines do:
;; this line causes cut/paste errors under windows (emacs 24)
;; (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
;; this alternative fixes windows problems but causes errors under linux (emacs 24)
(setq interprogram-paste-function 'x-selection-value)
I have had a go at making my .emacs platform conditional, e.g.:
;; this line causes cut/paste errors under windows (emacs 24)
(if (eq system-type 'gnu-linux) (setq interprogram-paste-function 'x-cut-buffer-or-selection-value) )
;; (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
;; this alternative causes errors under linux (emacs 24)
(if (eq system-type 'windows-nt) (setq interprogram-paste-function 'x-selection-value) )
;;(setq interprogram-paste-function 'x-selection-value)
this fixes the problem but this seems like a bit of a kludge...
The variable name changed in EMACS 24:
current-kill: Symbol's function definition is void: x-cut-buffer-or-selection-value
Open your .emacs and change:
'x-cut-buffer-or-selection-value)
to:
(setq interprogram-paste-function 'x-selection-value)
I found the answer in this posting:
http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg00638.html
How does Emacs behave if you didn't customize at all? i.e. start with
emacs -Q
?
I don't have Windows machine in front of me, but there nothing in my config that's Windows specific for cut/paste, and I never had any problems with 24, although I haven't tried the stable release yet.

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)))))