Upgrading Emacs

= Upgrade steps =


 * Remove or rename all other emacs versions from the system. Otherwise, you may get confused later on, when the wrong emacs version accidentally starts when double-clicking on some file.
 * Get the new emacs version.
 * Under Windows, use a precompiled binary, and place it somewhere so that the path does not contains spaces (just in case).
 * Under Linux, build emacs from source if you cannot find an appropriate source of pre-built binaries. See the building section below for details.
 * Under Windows, emacs looks for its configuration files under %APPDATA%.
 * If you have downloaded packages from a remote repository like MELPA in the past, now would be a good time to update them all. Run list-packages, go to the "Package" menu, choose "Refresh Package List" (package-menu-refresh) just in case, then "Mark Upgradable Packages" (package-menu-mark-upgrades), and then "Execute Actions" (package-menu-execute).
 * If you are running Cygwin under Windows, you will probably want to install package cygwin-mount. If Cygwin is not in the PATH, this package will complain that it cannot found the 'mount tool' . Customize group "cygwin-mount", variable "Cygwin Mount Cygwin Bin Directory", and set it to the right path, for example "C:\cygwin64\bin".
 * Under Linux or Cygwin, change your $EDITOR shell variable. For example:

# Using "--no-wait" here will probably break some programs # that expect the user editing to have finished when # emacsclient exits. export EDITOR="$HOME/emacs-24.5-bin/bin/emacsclient" # sudoedit creates a temporary file, and then overwrites # the target file with the edited copy. Note that option # "--no-wait" here would break this behavior. export SUDO_EDITOR="$HOME/emacs-24.5-bin/bin/emacsclient"


 * Create or amend your desktop's launcher shortcut.
 * Under KDE, use: "$HOME/emacs-24.5-bin/bin/emacs" %F The emacs icon for that launcher shortcut is here: $HOME/emacs-24.5-bin/share/icons/hicolor/scalable/apps
 * Under Windows, create a shortcut to runemacs.exe.
 * Configure double-click file opening.
 * Under KDE, use: /home/ /emacs-24.5-bin/bin/emacsclient --no-wait In order to amend Dolphin's "Open With..." menu, open the Properties of a file which matches the type you want to edit, and then klick on "File Type Options".
 * Under Windows, associate text files with emacsclientw.exe and set or amend user environment variable ALTERNATE_EDITOR to the full path of executable runemacs.exe . Then start a tool like FileTypesMan from NirSoft, search for emacsclientw.exe, and add argument --no-wait before parameter "%1". (untested) Alternatively, use the following commands: ftype emacs-file=c:\emacs-24.5\bin\emacsclientw.exe --no-wait "%1"  assoc .txt=emacs-file If emacs is already running, double-clicking on files with Unicode characters on their path will not work, those characters will get garbled inside emacs. If you know how to fix or work-around this issue, please drop me a line.
 * If you autostart emacs, adjust the path to emacs there too.
 * If you have any other scripts that have a hard-coded path to emacs or emacsclient, adjust them too. For example, I have a pipe-to-emacs-server.sh script on my system, so that I can comfortably redirect console output to emacs.
 * Make sure that your desktop environment (like KDE) is not eating some of your favourite key combinations (like Ctrl+F2) for its own functions like virtual desktop support. Otherwise, emacs will not get to see them at all.
 * Fix rgrep under Windows by customizing grep-find-template (in customize group grep). If you have Cygwin installed, this works for me:

C:\cygwin64\bin\find.  -type f  -exec /usr/bin/grep  --regexp= --with-filename --line-number --color=always {} +


 * Notes about rgrep above:
 * Setting this variable is hard, because emacs will run it as a Windows program, but find and grep expect the Unix escaping rules and so on.
 * Executable path "C:\cygwin64\bin\find" works even if Cygwin is not on your PATH.
 * Executable path "/usr/bin/grep" must be in Unix/Cygwin format, because find is a Cygwin executable.
 * The template does not need the base dir variable  because emacs changes to this directory before running find, so omitting  prevents encoding issues if the directory name contains international characters like 'é'.
 * The "+" and the end, rather than the usual ";", makes find behave like xargs, so the whole operation runs much faster.
 * Instead of specifying "--color=always" in the template, you could customizing "Grep Highlight Matches" to "Use --color=always", but that yields many warnings like "/usr/bin/grep: warning: GREP_OPTIONS is deprecated; please use an alias or script". This issue has been fixed in the upcoming emacs version 25.
 * You probably want to customize "Match face" to something other than yellow, which is the colour normally used for manually-highlighted text. Colour "pale green" does the trick for me.

= Building from source under Linux =


 * Download and unpack:

wget http://ftp.gnu.org/gnu/emacs/emacs-24.5.tar.gz tar -xzf emacs-24.5.tar.gz  cd emacs-24.5


 * Install dependencies. This works under Ubuntu:

sudo apt-get install build-essential sudo apt-get build-dep emacs24
 * 1) Satisfy most dependencies automatically.


 * Apparently that does not satisfy the Xaw3d dependency:

Does Emacs use -lXaw3d? no
 * But I do not actually know what type of scroll bar or whatever that Xaw3d package is. If you know more, please drop me a line.


 * Configure:

./configure --with-x-toolkit=gtk3 --prefix="$HOME/emacs-24.5-bin"


 * Now you can take a look at the configuration table at the end of the configuration log and see if everything looks alright.


 * Build and install:

make -j "$(( $(getconf _NPROCESSORS_ONLN) + 1 ))" && make install

= Unresolved issues =

If know how to fix or work-around any of these issues, please drop me a line.


 * When configuring the build, see unsatisfied dependency "Xaw3d" above.
 * With Ubuntu 14.04's emacs 24.3, you can drag-and-drop multiple files at once from a KDE Dolphin window. That does not work anymore. It could be a build configuration issue.
 * Under Windows, emacsclientw.exe does not pass Unicode characters in file paths correctly to an already-running emacs instance.