Setting Up .Emacs File for MAC Ruby Development

Setting up .emacs file for mac ruby development

Put the line (warn "Loading .emacs") as the first line of .emacs. When you start emacs does it show you that message in a warning buffer? If so, it at least started loading the file.

If this does nothing, try opening the file in emacs, and running M-x eval-buffer.

Also, at startup, does the Messages buffer indicate any errors in your .emacs? This is the most common reason for a .emacs not to take effect.

change emacs ruby-mode indent to 4 spaces

The tab-width setting only controls the width of a tab character, i.e. how many spaces a tab character is equivalent to when displayed in your buffer. It does not affect the number of spaces (or tabs) used for indenting your code.

For Ruby code, the indentation is controlled by the ruby-indent-level variable:

(setq ruby-indent-level 4)

How can I install emacs correctly on OS X?

You don't need some of those arguments your passing to brew to get the latest
emacs 26.1. Try the following

Remove emacs

brew uninstall emacs

Clean out any previously downloaded source files

brew cleanup

Check your brew installation is OK

brew doctor

The message you get when you run emacs --version indicates a partially installed version of emacs 24. Running brew doctor should help identify the problems.

Make sure your running the most recent brew

brew update

Upgrade any brew stuff you have in case any of them are pre-requisites

brew upgrade

then install emacs with

brew install emacs --with-cocoa --with-librsvg --with-imagemagick@6

Watch for messages from brew. During the install, brew use to advise running

brew linkapps emacs

afterwards to make sure the new version is linked to the /Applications folder
correctly. I suspect this may have been the missing step in your install. While the brew manual suggests this command is deprecated, it also says to use a cask version instead. I found some issues with the cask version, so prefer to use the locally built vers (cask version uses emacsforosx binaries). It isn't clear if you should still run linkapps when using the non cask version - however, the install should tell you, so make sure you look at all the output (the message is not at the end, but further up in the install process output).

The other arguments you had are only necessary if you want to install the latest
development version, which is not a good idea if your just starting out. all you
want is emacs 26.1

Make sure that /usr/local/bin is in your path before /usr/bin to avoid emacs
referencing the very old version of Emacs bundled with OSX.

How do I set up Aquamacs for Clojure development?

These are the steps I took to set them up without using ELPA. Hope this helps.

Get SLIME using MacPorts

sudo port -v install slime

Get paredit

curl -O http://mumble.net/~campbell/emacs/paredit.el

Get clojure & clojure-contrib

  • Either using MacPorts
sudo port -v install clojure clojure-contrib
  • Or downloading directly
curl -O http://build.clojure.org/snapshots/org/clojure/clojure/1.1.0-master-SNAPSHOT/clojure-1.1.0-master-20091202.150145-1.jar
curl -O http://build.clojure.org/snapshots/org/clojure/clojure-contrib/1.1.0-master-SNAPSHOT/clojure-contrib-1.1.0-master-20091212.205045-1.jar

Get clojure-mode and swank-clojure (Emacs side)

git clone http://github.com/technomancy/clojure-mode.git
git clone http://github.com/technomancy/swank-clojure.git

Get swank-clojure (Clojure side)

  • Either downloading pre-built jar file
curl -O http://repo.technomancy.us/swank-clojure-1.1.0.jar
  • Or building from source (assuming lein is installed)
cd path/to/dir/swank-clojure
lein jar

Put clojure, clojure-contrib and swank-clojure .jar files in ~/.swank-clojure or ~/.clojure (the default places where swank-clojure.el searches for them).


Add to either ~/.emacs or ~/Library/Preferences/Aquamacs Emacs/customization.el (change paths to match your own settings)

(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime/")
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime/contrib/")
;; Change these paths to match your settings
(add-to-list 'load-path "path/to/dir/clojure-mode/")
(add-to-list 'load-path "path/to/dir/swank-clojure/")
(add-to-list 'load-path "path/to/dir/paredit/")

;; Customize swank-clojure start-up to reflect possible classpath changes
;; M-x ielm `slime-lisp-implementations RET or see `swank-clojure.el' for more info
(defadvice slime-read-interactive-args (before add-clojure)
(require 'assoc)
(aput 'slime-lisp-implementations 'clojure
(list (swank-clojure-cmd) :init 'swank-clojure-init)))

(require 'slime)
(require 'paredit)
(require 'clojure-mode)
(require 'swank-clojure)

(eval-after-load "slime"
'(progn
;; "Extra" features (contrib)
(slime-setup
'(slime-repl slime-banner slime-highlight-edits slime-fuzzy))
(setq
;; Use UTF-8 coding
slime-net-coding-system 'utf-8-unix
;; Use fuzzy completion (M-Tab)
slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
;; Use parentheses editting mode paredit
(defun paredit-mode-enable () (paredit-mode 1))
(add-hook 'slime-mode-hook 'paredit-mode-enable)
(add-hook 'slime-repl-mode-hook 'paredit-mode-enable)))

;; By default inputs and results have the same color
;; Customize result color to differentiate them
;; Look for `defface' in `slime-repl.el' if you want to further customize
(custom-set-faces
'(slime-repl-result-face ((t (:foreground "LightGreen")))))

(eval-after-load "swank-clojure"
'(progn
;; Make REPL more friendly to Clojure (ELPA does not include this?)
;; The function is defined in swank-clojure.el but not used?!?
(add-hook 'slime-repl-mode-hook
'swank-clojure-slime-repl-modify-syntax t)
;; Add classpath for Incanter (just an example)
;; The preferred way to set classpath is to use swank-clojure-project
(add-to-list 'swank-clojure-classpath
"path/to/incanter/modules/incanter-app/target/*")))

How to automatically install Emacs packages by specifying a list of package names?

Based on comments by Profpatsch and answers below:

(defun ensure-package-installed (&rest packages)
"Assure every package is installed, ask for installation if it’s not.

Return a list of installed packages or nil for every skipped package."
(mapcar
(lambda (package)
;; (package-installed-p 'evil)
(if (package-installed-p package)
nil
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package)
package)))
packages))

;; make sure to have downloaded archive description.
;; Or use package-archive-contents as suggested by Nicolas Dudebout
(or (file-exists-p package-user-dir)
(package-refresh-contents))

(ensure-package-installed 'iedit 'magit) ; --> (nil nil) if iedit and magit are already installed

;; activate installed packages
(package-initialize)

One Directory in Emacs ECB ecb-source-path?

I figured out a solution to only show the directory from which I run emacs in the ECB window:

(defvar start-dir (getenv "PWD"))
(defvar start-dir-name (car (last (split-string start-dir "/"))))
(custom-set-variables
'(ecb-layout-name "left14")
'(ecb-layout-window-sizes (quote (("left14" (0.2564102564102564 . 0.6949152542372882) (0.2564102564102564 . 0.23728813559322035)))))
'(ecb-options-version "2.32")
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1))
'(ecb-source-path (list (list start-dir start-dir-name)))
'(ecb-tip-of-the-day nil)
'(ecb-tree-buffer-style (quote ascii-guides))
'(inhibit-startup-screen t))

grails emacs mode - Cannot open load file project-mode

grails-mode requires project-mode as mentioned on the emacs-grails-mode page. So, you'll also need to install project-mode.

Also grab the remaining groovy packages(all but grails-mode) from here.

emacs-grails-mode-ext is a modest contribution to grails-mode allowing you to run Grails commands directly from emacs. For a given project(project-mode), you can run Grails commands such as create-domain-class, create-service, etc.

I also use the function ido-find-file-in-tag-files from here, I bind it to C-x C-M-f .

Simple guide with emacs-grails-mode:

  • Create a project from the command line or eshell -> grails create-app yourapp
  • Using dired, go to your Grails project folder
  • M-x project-new -> to create a new project(project-mode)
  • M-x project-save -> Save the project
  • M-x project-load-and-select -> Your project-name as argument
  • There's also a Grails menu if you use the menubar

You could also use my current emacs setup here, if you have emacs24 installed. I believe that it's available for Ubuntu 12.04, but I'm not sure. I usually build emacs from source on OSX or I use emacs-snapshot in Ubuntu.

Hope this helps.



Related Topics



Leave a reply



Submit