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). If you are using Paradox instead of the default package manager, use Paradox/Filter Package List/By Upgrades (paradox-filter-upgrades) to conveniently filter by upgrades. Finally, "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 Xfce, use MenuLibre to add a launcher for: /home/ /emacs-25.2-bin/bin/emacsclient --no-wait %F Then right-click on a file, select "Open with...", and associate the file type with that launcher.
 * Under KDE, use: /home/ /emacs-25.2-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-26.2.tar.gz tar -xzf emacs-26.2.tar.gz  cd emacs-26.2


 * Install dependencies. This works under Ubuntu:

sudo apt-get install build-essential sudo apt-get build-dep emacs25  # You need to enable source packages first.
 * 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 CFLAGS="-g3 -O3 -march=native"  --with-x-toolkit=gtk3  --prefix="$HOME/emacs-26.1-bin"


 * The standard CFLAGS are "-g3 -O2", but you want maximum performance.


 * 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 --output-sync=recurse -j "$(( $(getconf _NPROCESSORS_ONLN) + 1 ))"  &&  make install-strip

= 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.