How can I have a portable Emacs? - windows

Is there a way run Emacs from a USB drive? I am a Windows user and I would like to be able use it on any PC without an Emacs install.

Yes, the "normal" Emacs distribution for Windows is precompiled and just runs without having to do any install. Just get one of the *.zip files from the usual place, unpack it onto a USB disk, and you can use it directly. (The actual binary is inside the "bin/" directory.)
The only thing you may want to do is set it up to look for ".emacs" always on the USB disk instead of on your hard drive; see
(info "(emacs) Windows HOME")
on how to do that.

You can read Emacs-related pages at PortableApps.com, and if they have not yet ported Emacs to their set of portable applications, then please ask them kindly to add Emacs to the list of text editors. With enough requests they will do this eventually.

There is a beta version of a Portable Apps version of emacs 23.2 here. Initial test works fine here.

Create a directory in the root of your USB drive called home.
Create site-start.el in the site-lisp folder and then copy this and you are all set to go.
(defvar %~dp0 (substring data-directory 0 3))
(defvar usb-home-dir (concat %~dp0 "home/"))
(setenv "HOME" usb-home-dir)

I have ported emacs to portable apps format.
http://esnm.sourceforge.net/download.html

Related

Running emacs completely from usb on windows [duplicate]

This question already has answers here:
How can I have a portable Emacs?
(5 answers)
Closed 9 years ago.
In few weeks I'll be on a competition for website development.
I can use Emacs from a usb stick. I can't write to system drives anything so all Emacs configs and plugins are needed to be loaded from the usb stick. These are rules so I would rather not break them.
So I think this can be done with setting load-path or recompiling emacs to look config files from the usb but I no idea how this would be done in practice.
GNU provides compiled binary releases of Emacs for Windows. They require no installation or compilation.
Download the version you want (the latest at the time of writing is emacs-24.3-bin-i386.zip).
Optionally, verify its signature with GnuPG.
Extract it to your flash drive.
If a %HOME% environment variable exists, Emacs will use this as your home directory. Setting %HOME% to D:\ will cause Emacs to read its configuration from D:\.emacs or D:\.emacs.d\init.el. It will also cause package.el to install packages to D:\.emacs.d\elpa\.
If you are permitted to modify environment variables for your user, go to Computer ⟶ Properties ⟶ Advanced system settings, click the Environment Variables button, and add or modify HOME, setting it whatever drive letter your flash drive gets assigned. You will need to reboot (or at least log out and back in) before this variable takes effect.
If you are not allowed to modify this variable, you can use set HOME=D:\ in cmd.exe, then execute Emacs from that shell. You may want to write a short batch script to do this and add it to your flash drive.
To run Emacs, use bin\runemacs.exe.

Default location for configuration files - MacOS?

In a cross-platform application, I am working with a configuration file that allows the user to override various defaults if he wishes to.
The problem I have is... where to place / look for this configuration file, especially with regards to MacOS X (which I never used and have no access to)? I know that MacOS X is based on Unix, but I also know that many things are done very much differently there...
My current choices:
Unix:
~/.config/<appname>/<appname>.cfg
Windows (shomewhat unsure about this one too, things seem to be all over the place here - %LOCALAPPDATA% or %USERPROFILE% seem to be valid choices too):
%APPDATA%/<appname>/<appname>.cfg
MacOS:
...?
Any comments, on MacOS or my other choices?
I think it must be ~/Library/Application Support/<appname>/<appname>.cfg
See the table in Mac App Programming Guide : "The Mac Application Environment" -> "Low-Level Details of the Runtime Environment" -> "The File System".
You can store it in the same manner you show for Unix/Linux above.
~ works the same way for home directories on OS X as UNIX platforms. Same goes for . in names for hidden directories.
Given the cross-platform needs you describe, I would do it exactly the same way on OS X as in your UNIX example.

Clojure REPL from USB drive

I'm trying to learn Clojure at the moment, but off to my parents this weekend. They have a Windows laptop, but I don't want to install anything...so is it possible to run a Clojure REPL solely with files installed on a USB drive?
The best portable clojure "environment" that I have come across is Lisp Cabinet.
It gives the option of multiple lisp environments, but you can choose to just have a clojure environment. It is a little dificult to discern from the website that it's portable, but the installer gives you the option of installing everything in one folder for a completely portable experience.
Edit: As for a repl, when you launch it, Lisp Cabinet gives you an emacs slime REPL for the environments that you choose (that would probably just be clojure).
Sure, absolutely this will work. If you install both Java and Clojure onto a flash drive, it will work just the same as if you installed it onto a normal hard drive.
As this blog post recommends you can set up a clj.bat file:
#ECHO OFF
java -cp clojure.jar clojure.lang.Repl
Just keep in mind that your parent's laptop won't have any environment variables set (i.e. PATH), so depending on where everything is located, you will need to tweak it to make sure java is recognized, and clojure.jar is on the classpath.
You could also install leiningen on the USB drive. Then call
/path/to/USB/lein.bat repl
Enjoy!

How to install new modes in emacs 23 on OS X?

I just downloaded the Haskell and J modes off of SourceForge, and I'm having trouble figuring out how to make them interface with emacs 23. Google searches yield detailed instructions for emacs 22, but it looks like changes have been made that make it hard to figure out where I'm supposed to stick the source files. The internal documentation seems to assume more experience with emacs internals than I currently have, and the problem has resisted solution for several days. Does anyone know how to get these modes up and running?
EDIT: Thanks to Untwisted for supplying the answer. Ultimately, my real problems were these:
1) I didn't know that .emacs was invisible to the OSX finder but was visible through the terminal.
2) It never occurred to me that I could modify .emacs while an instance of emacs was running.
Once I realized that those were my problems, I used C-x C-f to open ~/.emacs, copied the text of Untwisted's fix, and modified it to reflect my personal file paths. After that, everything worked.
Basically you need to put the .el files somewhere (I keep mine in ~/.emacs_extras/haskell-mode/ ), and edit your ~/.emacs file to load Haskell mode when appropriate. Example of a ~/.emacs file:
(load "~/.emacs_addons/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
That should make Haskell mode work. For more details, other options, etc: http://www.haskell.org/haskellwiki/Haskell_mode_for_Emacs

how to setup common emacs environment for windows and linux computers?

I use emacs for text editing and script development. I use both windows and ubuntu emacs 23.1 distribution.
Now I want both my linux and windows environment to replicate the same environment.
I will save my emacs environment here https://bitbucket.org/krish/emacs/, so file synchronisation will not be problem.
I don't have any different resolution settings for both the envionment
I use aspell which need specific path and different installer in windows and linux
I use perl, python, ruby mode along with other html, css, js-2 and nxml
Are there any specific way/advise to manage the common emacs environment between windows and linux? especially how to manage the program path?
There's no real straightforward way. You'd have to isolate most (if not all) your platform specific routines into different files and load them up after checking for platform.
Steve Yegge has some information on how he manages his .emacs file along with the actual code itself over here. One of his points is how he keeps is cross platform hackable. It's worth a read.
I have a very similar setup to yours (Emacs 22.1, 22.2, 23.1 on various Linux versions with and without X and Windows with and without Cygwin). My setup includes ELPA, auctex, emacsw32, CEDET, JDEE, nxml and various other elisp packages. I do not use whatever comes with the system but keep copies of those packages in subversion.
Majority of setup just works in all environments. Regarding paths, I think that majority of stuff one wants to call, such as aspell, can be called outside Emacs from command line too, so it`s worth putting them in $PATH thus avoiding having to specify full paths in Emacs.
For other things, I do
In .emacs:
; Load system-specific library and setup system-specific things that
; must be setup before main setup
(cond ((eq system-type 'windows-nt) (load-library "ntemacs-cygwin"))
((eq system-type 'gnu/linux) (load-library "linux"))
(t (load-library "default")))
(system-specific-setup)
; Set up things as usually, no more system-type queries.
Where in linux.el:
(defun system-specific-setup()
; Default font
(add-to-list
'default-frame-alist
'(font . "-Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-1"))
(setq my-frame-width 95)
(setq my-frame-height 56)
; Not much else
)
And in ntemacs-cygwin.el:
(defun system-specific-setup()
;; EmacsW32
(setq emacsw32-root (concat private-elisp-lib "EmacsW32"))
(add-to-load-path emacsw32-root)
;; Work around XSymbol initialization bug
;; ("C:\\ImageMagick\\convert" instead of system $PATH? Seriously?)
(setq x-symbol-image-convert-program "convert")
;; etcetera...
)
Basically it is a matter of setting things up on one system, trying them on another and factoring out whatever needs to be different to the system-specific-setup.
And the Steve Yegge´s article in Noufal´s answer is a very good one.
You can look to my emacs configs, where operations for differnet machines are splitted into separate files

Resources