I've been using vi quite a while, and with a Mac, I sometimes use TextMate, and finally, I found the greatness of emacs. And, it's very likely that I settle in emacs.
The problem is, I sometimes need the other (vi/TextMate) editor for doing something. It's not that emacs doesn't have the feature, it's just that I need the feature right now, and I know how to do that with the 'other' editor. And the same is true with the other editor.
My question is how can I launch the one editor from the other. It's not just launching an app, but launching an app with the file that I'm editing.
How can I launch vi or TextMate(mate) from emacs?
How can I launch emacs or mate from vi?
How can I launch vi or emacs from TextMate?
ADDED
After Jérôme Radix's answer, I came up with the following command.
(defun runmate ()
(interactive)
(runeditor "/Users/smcho/bin/mate"))
(defun runeditor (editor)
(let (filename (file-truename buffer-file-name))
(setq cmd (format "%s %s" editor (file-truename buffer-file-name)))
(save-window-excursion
(async-shell-command cmd))))
How can I launch vi or TextMate(mate) from emacs?
(async-shell-command "vi") ;; From Emacs 23.2
(shell-command "vi &") ;; Before Emacs 23.2
to launch TextMate, you need to install TextMate's command line tools, and then from emacs, it's (thx Chetan):
(async-shell-command "mate") ;; From Emacs 23.2
(shell-command "mate &") ;; Before Emacs 23.2
But the best thing to do is to open all 3 editors at the same time and switch between them.
Related
I installed emacs ver 24 in ubuntu and when i launch it > emacs "file" - emacs opens with 2 windows split vertically. One window has my "file" and the other window has the "Welcome to GNU Emacs .... " screen in it.
How do I stop it from opening the window with the "Welcome to GNU Emacs"? Do i need to add something to my .emacs file?
Right now I have tried :
(setq inhibit-splash-screen-t)
(setq inhibit-startup-message-t)
(setq initial-scratch-message nil)
(setq delete-other-windows t)
None of which prevent the second window from opening with the emacs welcome.
;; No emacs start-up message
(setq inhibit-startup-message t)
;; Consider also to start a server
(server-start)
Such that your emacs instance is reused when opening multiple files
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.
With this minimal init file:
(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")
Everything seems to work, such as slime-eval-defun and slime-complete-symbol, except for looking up documentation. M-x slime-describe-symbol RET print RET results in this error:
CLHS-ROOT: variable *CLHS-ROOT-DEFAULT* has no value
What do I need to add in my init file to make it work?
I also tried downloading the hyperspec tar file and extracting it to a directory, and this code:
(setq package-load-list '((slime t)))
(setq inferior-lisp-program "clisp"
common-lisp-hyperspec-root "c:/run/HyperSpec/"
common-lisp-hyperspec-symbol-table "c:/run/HyperSpec/Data/Map_Sym.txt")
(package-initialize)
(setq package-enable-at-startup nil)
(require 'slime)
(slime-setup)
(slime)
(find-file "~/t/del.lisp")
That doesn't work either. I do not know if the bug is in that init file, or in the SLIME version I am using, because this is my first time with SLIME.
Versions:
MS Windows 7
Emacs version 24.3.1 (probably latest stable)
SLIME version 20130626.1151 (latest from MELPA) (One from Marmalade says it can't compile nil, I don't know what that means and so I am using one from MELPA instead)
GNU CLISP 2.49 (latest stable)
UPDATE
C-c C-d f RET print RET works fine. This is bound to slime-describe-function, which is undocumented, and not listed in SLIME menu. There is also slime-documentation-lookup which is bound to C-c C-d C-d which can open documentation for variables (not just functions) in a browser, and that works too. Looks like only `slime-describe-symbol doesn't work.
I haven't done it on Windows, but if I were you, I'd try to do this with Quicklisp: (ql:quickload "clhs") and follow the printed directions.
I'd also get SLIME from Quicklisp via (ql:quickload "quicklisp-slime-helper"), but if your slime works ok, no real need.
Assuming that SLIME is installed from an emacs package archive (preferably MELPA) (and that GNU CLISP is installed), here is combination of relevant portions from How to install Common Lisp and SLIME on MS Windows:
Assuming starting from scratch after commenting out any SLIME customization code you already have, start by putting the following code to your init file which should be evaluated after package-initialize:
(setq inferior-lisp-program "clisp")
(setq slime-auto-connect 'ask)
(defun my-slime-setup ()
(require 'slime)
(slime-setup))
(defvar my--slime-setup-done nil)
(defun my-slime-setup-once ()
(unless my--slime-setup-done
(my-slime-setup)
(setq my--slime-setup-done t)))
(defadvice lisp-mode (before my-slime-setup-once activate)
(my-slime-setup-once))
What that does is defining my-slime-setup and make sure the function runs just once if you are using SLIME that day. my-slime-setup is also a container to which you can add your own SLIME customization code.
Now to connect the downloaded documentation to SLIME, extract the downloaded archive and you will get a folder with name Hyperspec, and then you move that folder to the Emacs bin directory, or its parent directory, or its grandparent directory, Put the following code in Emacs init file.
(defun my-hyperspec-setup ()
(let ((dir (locate-dominating-file invocation-directory "HyperSpec/")))
(if dir
(progn
(setq common-lisp-hyperspec-root (expand-file-name "HyperSpec/" dir)))
(warn "No HyperSpec directory found"))))
and add my-hyperspec-setup to my-slime-setup like this:
(defun my-slime-setup ()
(my-hyperspec-setup)
(require 'slime)
(slime-setup))
and restart Emacs.
And now when you do M-x slime-describe-symbol RET print RET in a lisp buffer, it should show the description of PRINT in another buffer.
I should confess that I am sourcing from my own article and also answering my own question after about 8 months. The answer is tested with latest SLIME from MELPA and on a vanilla GNU Emacs.
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.
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)))))