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

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

Related

Scheme get last command in guile

Normally in a terminal (or any other command prompt I've previously used) I'll press the up key to get the last entered command. However, when doing that in the guile interpreter, I just get:
scheme#(guile-user) [1]> ^[[A
What is the easiest way to get the last entered-in command in guile?
Command-line REPLs are often feature-poor. For Guile, a better experience can be had by, for example, running under Geiser in emacs. This allows a running REPL in an emacs buffer, with much better control. As a long-term solution, I would suggest learning how to do something like this.
There is a bit of a learning curve to get productive in emacs (not as much as people often seem to fear, though). Fortunately, Guile provides a solution for those who wish to stick with the regular Guile REPL.
While it is not enabled by default, Guile can make use of the GNU Readline library. This allows navigation of the REPL expression history via the up- and down-arrow keys. To enable this feature from the REPL, enter:
scheme#(guile-user)> (use-modules (ice-9 readline))
scheme#(guile-user)> (activate-readline)
When Guile is started in interactive mode, it first loads the .guile init file from the users home directory. You can take advantage of this by adding the above two lines to the .guile file (create a new .guile file for this purpose if one does not already exist):
;;; Guile Scheme Init File
;; Activate Readline
;; allows navigation of expression history in REPL
(use-modules (ice-9 readline))
(activate-readline)
After updating the .guile file, whenever Guile is run in interactive mode, you will automatically have the Readline functionality.

Emacs opens Windows network logon prompt

I recently, for work reasons, had to switch back from using Linux to using Windows on my laptop. I have not changed my emacs configuration in any way, but now when I start up emacs, twice I get a "Windows Security" network login prompt for a server I previously had mapped a shared folder to. Ever since I deleted that shared folder, emacs now prompts me twice during the startup sequence to log into the server. Nothing in my config files points to this server, and I don't have this problem on any other machine where I use the same configuration.
Any idea why this might be happening and how to make it stop?
EDIT:
I've identified one line of the config file that triggers it. It's
(setq org-completion-use-ido t)
(setq ido-everywhere t)
(setq ido-max-directory-size 100000)
(ido-mode (quote both)) ;; Evaluating this line pulls it up.
Based on the original poster having narrowed down the issue to ido-mode, the likely suspect is the file where the variable ido-save-directory-list-file points to.
The printout for describe-variable of the aforementioned variable is as follows:
ido-save-directory-list-file is a variable defined in `ido.el'.
Its value is "~/.emacs.d/ido.last"
Documentation:
File in which the Ido state is saved between invocations.
Variables stored are: `ido-last-directory-list', `ido-work-directory-list',
`ido-work-file-list', and `ido-dir-file-cache'.
Must be set before enabling Ido mode.
You can customize this variable.
This variable was introduced, or its default value was changed, in
version 24.4 of Emacs.

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 can I have a portable Emacs?

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

Do the vi and emacs implementations for Windows behave like their Unix counterparts?

If not, what are the significant differences?
Edit: Daren Thomas asks:
which ones?
I use gvim on Windows and MacVim on the mac. Seem similar enough to be the same to me...
By which ones, I'm guessing that you mean a specific implementation of vi and emacs for Windows. I'm not sure as I thought there were only one or two. I'm looking for the ones that are closest to the Unix counterparts.
I use GNU emacs built for Windows, and have found very few, if any, differences. There's the option to load your .emacs file from _emacs or .emacs (although .emacs works fine on XP and above). You can configure it to use Windows-style or Unix-style line endings by default (which I suppose you could do on a Unix system too...).
You may want to tweak such settings as Emacs's startup directory and home directory. To do the former, modify the shortcut that starts emacs. To do the latter, add a HOME environment variable - this will control where your .emacs is loaded from. For more information, check the always-excellent EmacsWiki's MsWindowsInstallation page.
which ones?
I use gvim on Windows and MacVim on the mac. Seem similar enough to be the same to me...
GNU Emacs has long been working natively on Windows as part of the main source, and can be compiled with Visual Studio (you can also find some pre-compiled binaries). As far as I know, there are no significant differences.
There are quite a few vi clones (e.g. vim) and also various Emacs implementations (Gnu Emacs vs. XEmacs spring to mind).
These clones differ on Unix themselves and will thus also differ on Windows.
One thing I found with vim is that the directory structure for plugins etc. is very different on Windows - ~/vim.rc translates to %HOME%\vim_rc (or similar, depends on stuff I don't understand), vim tends to save stuff like plugins under C:\Program Files\vim\... instead of ~/.vim/...
The Windows versions typically use the same base source code as the "regular", Unix-based versions. There may be sections of the code that are specific to Windows, just as there are sections specific to certain flavours of Unix. In general, though, the Windows versions of these packages will behave identically to the Unix ones, except where this is not possible (for example, gvim in Windows will use Windows GUI elements, of course).

Resources