Open DrRacket .rkt with emacs - emacs

Is it possible to run smoothly files saved by DrRacket?
for example if I save the following lines in a file called test.rkt with DrRacket and want to run it with emacs. How would I do this?
(require lang/htdp-intermediate)
; this is a test ; and a box comment-out with a box
;example
(check-expect (doubleN 2) 4)
;define
(define (doubleN nat)
(* 2 nat))
(doubleN 4)

The steps are:
Install geiser in emacs following the instructions on the Geiser website.
Open the file test.rkt in emacs.
Geiser mode should be active. If not use M-x geiser-mode and follow the prompts.
Press C-c C-a to start/enter the REPL and load test.rkt as the module.
If you make changes to test.rkt in its emacs buffer, save the changes with C-x C-s before reloading the module into the REPL with C-c C-a.

Related

emacs opening 2 windows in ubuntu - why?

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

Why Emacs project C-c p is undefined?

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.

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 identation works only in terminal (-nw)

I have GNU Emacs 23.1.1, on Ubuntu 10.10.
I have to following .emacs:
(custom-set-variables
'(cua-mode t nil (cua-base))
'(inhibit-startup-screen t)
)
(show-paren-mode 1)
(setq show-paren-delay 0)
;; perl mode stuff
(fset 'perl-mode 'cperl-mode)
(setq cperl-indent-level 4
cperl-close-paren-offset -4
cperl-continued-statement-offset 0
cperl-indent-parens-as-block t
cperl-tab-always-indent t
cperl-invalid-face nil
)
When I do $ emacs -nw the tab indentation works fine. When I launch the GUI version with $ emacs tab indentation doesn't work. I only get space indentation.
How can I get tab indentation in the GUI as well?
The cperl conf was taken from emacswiki
The emacs packages I have:
$ dpkg -l | grep emacs
ii emacs 23.1+1-4ubuntu7.2+maverick1 The GNU Emacs editor (metapackage)
ii emacs-goodies-el 33.6ubuntu1 Miscellaneous add-ons for Emacs
ii emacs-snapshot 1:20090909-1 The GNU Emacs editor (development snapshot)
ii emacs-snapshot-bin-common 1:20090909-1 The GNU Emacs editor's shared, architecture dependent files
ii emacs-snapshot-common 1:20090909-1 The GNU Emacs editor's common infrastructure
ii emacs23 23.1+1-4ubuntu7.2+maverick1 The GNU Emacs editor (with GTK+ user interface)
ii emacs23-bin-common 23.1+1-4ubuntu7.2+maverick1 The GNU Emacs editor's shared, architecture dependent files
ii emacs23-common 23.1+1-4ubuntu7.2+maverick1 The GNU Emacs editor's shared, architecture independent infrastructure
ii emacsen-common 1.4.19ubuntu1 Common facilities for all emacsen
EDIT: Sorry, but I just noticed that I hadn't studied the behaviour correctly. In both gui and -nw, when I edit a file already indented in tabs, it uses tabs, whereas when I edit a new file, it indents it with spaces.
First, check the *Messages* and *Warnings* buffers on startup. There might be a hint as to what's failing there. In particular, *Messages* should list all the startup files that emacs is loading; on Ubuntu, this will include files in /etc/emacs as well as your .emacs.
If that doesn't help, try running your .emacs interactively in the emacs debugger. Start emacs with emacs -nw -q and load .emacs into a buffer. Run M-x edebug-all-forms then run M-x eval-buffer. Press space repeatedly to step through the file.
Edit: Check the value of indent-tabs-mode in a perl buffer in both of your environment. This is used to control whether to indent with tab characters or spaces. Adding (setq-default indent-tabs-mode t) should force emacs to indent with tab characters.

Calling vim or TextMate from emacs

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.