https://wiki.archlinux.org/api.php?action=feedcontributions&user=Titan-c&feedformat=atomArchWiki - User contributions [en]2024-03-29T09:37:16ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Talk:Mediawiki-el&diff=488430Talk:Mediawiki-el2017-09-02T17:36:17Z<p>Titan-c: Created page with "This emacs extension does open the Arch wiki but it is incapable of saving the changes. There seems to be an API problem, but I don't understand Elisp nor the media wiki API t..."</p>
<hr />
<div>This emacs extension does open the Arch wiki but it is incapable of saving the changes. There seems to be an API problem, but I don't understand Elisp nor the media wiki API to debug this.</div>Titan-chttps://wiki.archlinux.org/index.php?title=User:Titan-c&diff=488428User:Titan-c2017-09-02T15:40:49Z<p>Titan-c: Created page with "testing creating a wiki page"</p>
<hr />
<div>testing creating a wiki page</div>Titan-chttps://wiki.archlinux.org/index.php?title=Emacs&diff=488427Emacs2017-09-02T15:12:53Z<p>Titan-c: /* Alternatives */ add remacs, because I use this port of emacs</p>
<hr />
<div>[[Category:Development]]<br />
[[Category:Text editors]]<br />
[[de:Emacs]]<br />
[[es:Emacs]]<br />
[[fr:Emacs]]<br />
[[ja:Emacs]]<br />
[[sr:Emacs]]<br />
[[zh-hans:Emacs]]<br />
[[Wikipedia:Emacs|Emacs]] is an extensible, customizable, self-documenting real-time display editor. At the core of Emacs lies an [[Wikipedia:Emacs Lisp|Emacs Lisp]] interpreter, the language in which the majority of Emacs' built-in functionality and extensions are implemented. GNU Emacs uses GTK as its X toolkit, though it functions equally well within a CLI environment. The text-editing capabilities of Emacs are often compared to that of [[vim]].<br />
<br />
== Installation ==<br />
<br />
Emacs comes in several variants (sometimes referred to as ''emacsen''). The most common of these is [http://www.gnu.org/software/emacs/ GNU Emacs].<br />
<br />
[[Install]] {{Pkg|emacs}}, available in the [[official repositories]]. If you usually work in a terminal, you may prefer the {{Pkg|emacs-nox}} variant without GTK+ (nor sound and other fancy stuff).<br />
Be aware that the text version comes with some drawbacks: it supports less colors and less features for font handling (size change in live, various sizes in one document, and so on). Besides, emacs-nox has some limitation with advanced features like the Speedbar or GUD (the debugging environment), and is somewhat slower when handling complex faces (a "face" is the visual appearance of text in Emacs).<br />
<br />
If you want to fully enjoy all the extended features of Emacs without installing a daunting amount of dependencies, you can use the PKGBUILD to customize your needs. Using anything else than {{ic|gtk3}} you can get rid of gconf. Image and sound support can be disabled as well. Run {{ic|./configure --help}} in Emacs source folder to list all available options.<br />
{{hc|PKGBUILD|<nowiki><br />
# ...<br />
./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib \<br />
--localstatedir=/var --with-x-toolkit=gtk2 --with-xft \<br />
--without-gconf --without-sound<br />
# ...<br />
</nowiki>}}<br />
<br />
== Running Emacs ==<br />
<br />
Before launching emacs, you should know how to close it (especially if you run it in a terminal): use the<br />
{{ic|Ctrl+x}}{{ic|Ctrl+c}} key sequence.<br />
<br />
To start Emacs run:<br />
<br />
$ emacs<br />
<br />
or, to use it from the console:<br />
<br />
$ emacs -nw<br />
<br />
or, for fast loading (no .emacs) and editing within CLI:<br />
<br />
$ emacs -Q -nw<br />
<br />
If you installed the nox version, 'emacs' and 'emacs -nw' will be the same.<br />
<br />
A file name can also be provided to open that file immediately:<br />
<br />
$ emacs filename.txt<br />
<br />
=== No Colors ===<br />
<br />
By default, Emacs starts with a color theme showing hyperlinks in dark blue. To start Emacs without any color theme or scheme:<br />
<br />
$ emacs -nw --color=no<br />
<br />
This will cause all text to appear in white color only.<br />
<br />
=== As a daemon ===<br />
<br />
In order to avoid reloading the Emacs config file every time Emacs starts, you can run Emacs as a daemon:<br />
<br />
$ emacs --daemon<br />
<br />
You may then connect to the daemon by running: <br />
<br />
$ emacsclient -nc<br />
<br />
Which creates a new frame {{ic|-c}} (use {{ic|-t}} if you prefer to use it in the terminal) and does not hog the terminal {{ic|-n}} ({{ic|--no-wait}}).<br />
Note that some programs such as Mutt or Git (for commit messages) wait for the editor to finish, so you cannot use the {{ic|-n}} parameter.<br />
If your default editor is set to use it, you will have to specify an alternate editor (''e.g.'' {{ic|emacsclient -a "" -t}}) for those programs.<br />
<br />
=== As a systemd unit ===<br />
<br />
The old system unit method had some caveats. It gave a limited shell environment which restricted shell calls, so we will be using a user unit, which tends to work a lot better than naively calling ''emacs --daemon''.<br />
<br />
Create a systemd unit for emacs:<br />
<br />
{{Note|1=Such a unit file is planned for inclusion in Emacs 26.1, see [https://debbugs.gnu.org/cgi/bugreport.cgi?bug=16507 emacs bug 16507].}}<br />
<br />
{{hc|~/.config/systemd/user/emacs.service|<nowiki><br />
[Unit]<br />
Description=Emacs: the extensible, self-documenting text editor<br />
<br />
[Service]<br />
Type=forking<br />
ExecStart=/usr/bin/emacs --daemon<br />
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"<br />
Restart=always<br />
<br />
[Install]<br />
WantedBy=default.target<br />
</nowiki>}}<br />
<br />
You need to start and enable the unit so that it gets started on every boot (note - DO ''NOT'' run this as root - we want them for our user, not for the root user):<br />
<br />
$ systemctl --user enable --now emacs<br />
<br />
Note that systemd user units do not inherit environment variables from a login shell (like {{ic|~/.bash_profile}}), so you may want to set the variables in {{ic|~/.pam_environment}} instead. See [[Systemd/User]] for more information.<br />
<br />
== Usage ==<br />
<br />
Although Emacs is complex, it will not take long to begin to understand the benefits which the level of customization and extensibility bring. Furthermore, the comprehensive variety of extensions already available allows it to be transformed into a powerful environment for almost any form of text-editing.<br />
<br />
Emacs has an excellent built-in tutorial which can be accessed by clicking the first link on the splash screen; by selecting ''Help->Emacs Tutorial'' from the menu or by pressing 'F1' followed by 't'.<br />
<br />
Emacs is self-documenting by design. As such, a great deal of information is available to determine the name of a specific command or its keybinding, for example. See all contextual help bindings with '''C-h C-h'''.<br />
<br />
Emacs also includes a set of reference cards, useful for beginners and experts alike, see {{ic|/usr/share/emacs/<version>/etc/refcards/}} (substitute <version> for your version of emacs).<br />
<br />
Emacs empowers the users with a tremendous amount of features, including:<br />
keyboards macros, rectangular regions, whitespace cleanup, bookmarks, desktop session, various shells, spell checking, tables, semantic analysis...<br />
<br />
=== The manuals ===<br />
<br />
If you really want to master Emacs, the most recommended source of documentation remains the official manuals:<br />
* Emacs: the complete Emacs user manual.<br />
* Emacs FAQ.<br />
* Emacs Lisp Intro: if you never used any programming language before.<br />
* Elisp: if you are already familiar with a programming language.<br />
<br />
You can access it as PDFs from [http://www.gnu.org/software/emacs/manual/ GNU.org] or directly from Emacs itself thanks to the embedded 'info' reader: '''C-h i'''. Press '''m''' to choose a book.<br />
<br />
Some users prefer to read books using 'info' because of its convenient shortcuts, its paragraphs adapting to window width and the font adapted to current screen resolution. Some find it less irritating to the eyes. Finally you can easily copy content from the book to any Emacs buffer, and you can even execute Lisp code snippets directly from the examples.<br />
<br />
You may want to read the '''Info''' book to know more about it: '''C-h i m info <RET>'''.<br />
Press '''?''' while in info mode for a quick list of shortcuts.<br />
<br />
== Tips and tricks ==<br />
<br />
=== TRAMP ===<br />
<br />
TRAMP (Transparent Remote Access, Multiple Protocols) is an extension which, as its name suggests, provides transparent access to remote files across a number of protocols. When prompted for a filename, entering a specific form will invoke TRAMP. Some examples:<br />
<br />
To prompt for the root password before opening /etc/hosts with root permissions:<br />
<br />
C-x C-f /sudo::/etc/hosts<br />
<br />
To connect to 'remotehost' as 'you' via SSH and open the file ~/example.txt:<br />
<br />
C-x C-f /ssh:you@remotehost:~/example.txt<br />
<br />
The path for TRAMP is typically of the form '/[protocol]:[[user@]host]:<file>'. <br />
<br />
To connect to 'myhost' as 'you' and edit /etc/hosts with sudo:<br />
<br />
/ssh:you@remotehost|sudo:remotehost:/etc/hosts<br />
<br />
TRAMP supports much more than the examples above might indicate. For more information refer to the TRAMP info manual, which is distributed with Emacs.<br />
<br />
=== Using Emacs as git mergetool ===<br />
<br />
By default, Git provides support for using Emacs' Emerge mode as a merge tool. However you may prefer the Ediff mode. Unfortunately this mode is not supported by git for technical reasons. There is still a way to use it by evaluating some elisp code upon emacs call.<br />
<br />
{{hc|.gitconfig|<nowiki><br />
[mergetool.ediff]<br />
cmd = emacs --eval \" (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \\\"Merge buffer saved in: %s\\\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\"))\" <br />
<br />
[merge]<br />
tool = ediff<br />
</nowiki>}}<br />
<br />
Note that the command has to be on a single line.<br />
In the above example, we launch a new instance of Emacs. You might want to use emacsclient for quicker startup; it is not recommended though since the Ediff call is not really clean: it could mess with your current Emacs session.<br />
<br />
If you want an instant startup you can use the '''-q''' parameter. If you want to launch Emacs quickly while preserving at least a part of your configuration, you can call Emacs with<br />
emacs -q -l ~/.emacs-light<br />
where the light configuration file loads only what you need for Ediff.<br />
<br />
See [http://kerneltrap.org/mailarchive/git/2007/7/1/250424 kerneltrap.org]{{Dead link|2017|06|02}} and [http://stackoverflow.com/questions/1817370/using-ediff-as-git-mergetool stackoverflow] for more details on this trick and the Ediff issue.<br />
<br />
=== Using Caps Lock as Control key ===<br />
<br />
Some users like this behavior to avoid the so-called 'emacs pinky'. If you want to try it on X, just run <br />
<br />
$ setxkbmap -option 'ctrl:nocaps'<br />
<br />
Alternatively, to '''swap''' these keys, run<br />
<br />
$ setxkbmap -option 'ctrl:swapcaps'<br />
<br />
To set this permanently, consider adding it to your {{ic|.xinitrc}} file. <br />
<br />
Now, if you ever need to upcase an region, just use the default {{ic|C-x C-u}} keybinding, which calls the {{ic|upcase-region}} function.<br />
<br />
See [http://ergoemacs.org/emacs/swap_CapsLock_Ctrl.html] for an alternative approach.<br />
<br />
If you are missing your Caps Lock function, map it as both "Shift" at same time.<br />
<br />
$ setxkbmap -option "shift:both_capslock"<br />
<br />
=== Multiplexing emacs and emacsclient ===<br />
<br />
Opening a new file in the same {{ic|emacs-session}} requires the use of {{ic|emacsclient}}. {{ic|emacs}} command can be itself wrapped to do the smarter job to open the file if the session exists.<br />
<br />
To start session you need to {{ic|start-server}}. This snippet will create server in first session of emacs. Add this to your {{ic|emacs}} configuration file.<br />
{{hc|.emacs or .emacs.d/init.el|<br />
(require 'server)<br />
(unless (server-running-p)<br />
(server-start))<br />
}}<br />
<br />
Shell alias method is not adequate for this since you also need to pass variables or start the independent session of your own. Add this to the {{ic|.bashrc}} or any rc file of your shell. This will make your {{ic|$ emacs}} command behave like emacsclient if the argument is passed.<br />
<br />
<nowiki><br />
function emacs {<br />
if [[ $# -eq 0 ]]; then<br />
/usr/bin/emacs # "emacs" is function, will cause recursion<br />
return<br />
fi<br />
args=($*)<br />
for ((i=0; i <= ${#args}; i++)); do<br />
local a=${args[i]}<br />
# NOTE: -c for creating new frame<br />
if [[ ${a:0:1} == '-' && ${a} != '-c' ]]; then<br />
/usr/bin/emacs ${args[*]}<br />
return<br />
fi<br />
done<br />
setsid emacsclient -n -a /usr/bin/emacs ${args[*]}<br />
} </nowiki><br />
<br />
If you want to run the it in new session just do {{ic|emacs <file> -}}.<br />
<br />
=== Multiple configurations ===<br />
<br />
You can use several configurations and tell Emacs to load one or the other.<br />
<br />
For example, let us define two configuration files.<br />
<br />
{{hc|.emacs|<br />
(load "~/.emacs.d/main" nil t)<br />
(load "~/.emacs.d/functions" nil t)<br />
(load "~/.emacs.d/modes" nil t)<br />
(load "~/.emacs.d/plugins" nil t)<br />
(load "~/.emacs.d/theme" nil t)<br />
}}<br />
<br />
This is the full configuration we load for the daemon. But the ''plugins'' file is huge and slow to load. If we want to spawn a new Emacs instance that does not need the ''plugins'' features, it can be cumbersome to load it everytime in the long run.<br />
<br />
{{hc|.emacs-light|<br />
(load "~/.emacs.d/main" nil t)<br />
(load "~/.emacs.d/functions" nil t)<br />
(load "~/.emacs.d/modes" nil t)<br />
(load "~/.emacs.d/theme" nil t)<br />
}}<br />
<br />
And now we launch Emacs with<br />
emacs -q -l ~/.emacs-light<br />
You can create an alias to ease the call.<br />
<br />
=== Local and custom variables ===<br />
<br />
You can define variables in your configuration file that can be later one modified locally for a file.<br />
<br />
(defcustom my-compiler "gcc" "Some documentation")<br />
<br />
Now in any file you can define local variables in two ways:<br />
* On the very first line, write<br />
// -*- my-compiler:g++; mode:c++ -*-<br />
* If you cannot (or do not want to) write this on the first line, you can put it at the end:<br />
// Local Variables:<br />
// my-compiler: g++<br />
// mode: c++<br />
// End:<br />
<br />
Note that the beginning characters need to be comments for the current language, that's why here we used two backslashes for C++. For Elisp you would use<br />
;; -*- mode:emacs-lisp -*-<br />
<br />
There is two functions that may help you in defining the variables: ''add-file-local-variable'' and ''add-file-local-variable-prop-line''.<br />
<br />
Finally, custom variable are considered insecure by default. If you try to open a file that contains local variable redefining insecure custom variables, Emacs will ask you for confirmation.<br />
<br />
If you know what you are doing, you can declare the variable as secure, thus removing the Emacs prompt for confirmation. You need to specify a predicate that any new value has to verify so that it can be considered safe.<br />
<br />
(defcustom my-compiler "gcc" "Some documentation" :safe 'stringp)<br />
<br />
In the previous example, if you attempt to set anything else than a string, Emacs will consider it insecure.<br />
<br />
=== Custom colors and theme ===<br />
<br />
Colors can be easily customized using the ''face'' facility.<br />
(set-face-background 'region "color-17")<br />
(set-face-foreground 'region "white")<br />
(set-face-bold-p 'font-lock-builtin-face t ) <br />
<br />
You can have let Emacs tell you the name of the face where the point is. Use the ''customize-face'' function for that. The facility will show you how to set colors, bold, underline, etc.<br />
<br />
Emacs in console can handle 256 colors, but you will have to use an appropriate terminal for that. For instance URxvt has support for 256 colors. You can use the ''list-colors-display'' for a comprehensive list of supported colors. This is highly terminal-dependent.<br />
<br />
See also:<br />
<br />
* https://www.emacswiki.org/emacs/ColorThemes<br />
* https://www.gnu.org/software/emacs/manual/html_node/emacs/Custom-Themes.html<br />
<br />
=== SyncTeX support ===<br />
<br />
Emacs is a powerful LaTeX editor. This is mostly due to the fact you can adapt or create a LaTeX mode to fit your needs best.<br />
<br />
Still, there might be some challenges, like SyncTeX support. First you need to make sure your TeX distribution has it. If you installed TeX Live manually, you may need to install the ''synctex'' package.<br />
# umask 022 && tlmgr install synctex<br />
<br />
SyncTeX support is viewer-dependent. Here we will use Zathura as an example, so the code needs to be adapted if you want to use another PDF viewer.<br />
<br />
(defcustom tex-my-viewer "zathura --fork -s -x \"emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"'\"'\"%{input}\"'\"'\")) (goto-line %{line}))'\"" <br />
"PDF Viewer for TeX documents. You may want to fork the viewer<br />
so that it detects when the same document is launched twice, and<br />
persists when Emacs gets closed.<br />
<br />
Simple command:<br />
<br />
zathura --fork<br />
<br />
We can use<br />
<br />
emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'<br />
<br />
to reverse-search a pdf using SyncTeX. Note that the quotes and double-quotes matter and must be escaped appropriately."<br />
:safe 'stringp)<br />
<br />
Here we define our custom variable. If you are using AucTeX or Emacs default LaTeX-mode, you will have to set the viewer accordingly.<br />
<br />
Now open a LaTeX source file with Emacs, compile the document, and launch the viewer. Zathura will spawn. If you press {{ic|Ctrl+Left click}} Emacs should place the point at the corresponding position.<br />
<br />
=== Syntax highlighting for systemd Files ===<br />
<br />
You can use [https://github.com/holomorph/systemd-mode systemd-mode].<br />
<br />
Alternatively, you can simply tell emacs to colour systemd files (services, timer, etc.), by adding this to your init file:<br />
<br />
(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.timer\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.mount\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.automount\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.slice\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.path\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.netdev\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.network\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.link\\'" . conf-unix-mode))<br />
(add-to-list 'auto-mode-alist '("\\.automount\\'" . conf-unix-mode))<br />
<br />
=== Clipboard support for emacs-nox ===<br />
<br />
To use the [[Xorg]] clipboard in emacs-nox, [[install]] {{Pkg|xclip}} and add the following function to {{ic|~/.emacs}} [https://lists.gnu.org/archive/html/help-gnu-emacs/2014-08/msg00189.html]<br />
<br />
{{bc|1=<br />
;; use xclip to copy/paste in emacs-nox<br />
(unless window-system<br />
(when (getenv "DISPLAY")<br />
(defun xclip-cut-function (text &optional push)<br />
(with-temp-buffer<br />
(insert text)<br />
(call-process-region (point-min) (point-max) "xclip" nil 0 nil "-i" "-selection" "clipboard")))<br />
(defun xclip-paste-function()<br />
(let ((xclip-output (shell-command-to-string "xclip -o -selection clipboard")))<br />
(unless (string= (car kill-ring) xclip-output)<br />
xclip-output )))<br />
(setq interprogram-cut-function 'xclip-cut-function)<br />
(setq interprogram-paste-function 'xclip-paste-function)<br />
))<br />
}}<br />
<br />
{{Tip|You may also enable terminal mouse support by adding:<br />
{{bc|1=<br />
;; xterm mouse support<br />
(require 'mouse)<br />
(xterm-mouse-mode t)<br />
}}<br />
See also [http://www.opensource.apple.com/source/emacs/emacs-51/emacs/lisp/mwheel.el mwheel.el].}}<br />
<br />
== Extensions ==<br />
<br />
Emacs includes hundreds of modes, libraries and other extensions, with many more available to further Emacs' capabilities. Most of these come with instructions detailing any changes needed to be made in {{ic|~/.emacs}}. These instructions are generally found in the comment block at the beginning of an elisp source file, or in a README (or similar), should the extension consist of multiple source files.<br />
<br />
You can use the [http://tromey.com/elpa/ Emacs Lisp Package Archive (ELPA)] to automatically install packages. See the manual for instructions. ELPA is included with Emacs 24 and above; it is an accepted part of the Emacs ecosystem. Also, check out [http://melpa.milkbox.net/ MELPA] for additional packages.<br />
<br />
{{Tip|Use {{ic|M-x list-packages}} to get a list of available packages for installation.}}<br />
<br />
A number of popular extensions are available as packages in the 'community' repository, and more still, via [[AUR]]. The name of such packages have a 'emacs-' prefix (for example, emacs-lua-mode). In many cases, the changes which need to be made in {{ic|~/.emacs}} are shown during the installation of the package.<br />
<br />
You can load extensions using the ''require'' function. For instance<br />
(require 'mediawiki)<br />
<br />
If you try using the same configuration file on a machine where the extension is not installed, Emacs will primpt for an error. Besides, all extension-specific code would be parsed for nothing.<br />
<br />
The trick is to test the return value of ''require'':<br />
<br />
(when (require 'mediawiki nil t)<br />
(setq mediawiki-site-alist<br />
'(("ArchLinux" "https://wiki.archlinux.org/" "UserName" "" "Main Page")))<br />
(setq mediawiki-mode-hook<br />
(lambda ()<br />
(visual-line-mode 1)<br />
(turn-off-auto-fill)))))<br />
<br />
Should instructions describing how to activate a specific extension not be available in the aforementioned location(s), check for a corresponding page in the [http://emacswiki.org/ Emacs Wiki], which will almost certainly provide an example configuration. The Emacs Wiki is also an excellent resource for discovering even more extensions.<br />
<br />
{{Tip|A few popular extensions worth checking out: AucTeX, auto-complete, company, el-doc, emms, helm, Magit, multiple-cursors, Org-mode, Projectile, yasnippet.}}<br />
<br />
Since we are at it, you may be a contributor to Arch Linux Wiki, or any Mediawiki-based website. Then emacs will become your best friend thanks to the [[Emacs Mediawiki]] extension. Check the dedicated page for more details.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Colored output issues ===<br />
<br />
By default, the Emacs shell will show raw escape sequences used to print colors. In other words, it will display strange symbols in place of the desired colored output.<br />
<br />
Including the following into {{ic|~/.emacs}} amends the problem:<br />
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)<br />
<br />
=== Problems displaying characters in X Windows ===<br />
<br />
If when you start emacs in X windows all the characters in the main window are white boxes with black borders (the ones you see if you try to view characters for which you do not have the correct font installed), you need to install {{Pkg|xorg-fonts-75dpi}} and/or {{Pkg|xorg-fonts-100dpi}} and restart X windows.<br />
<br />
=== Slow startup ===<br />
<br />
{{Tip|To eliminate startup time, users may want to consider running Emacs [[#As a systemd unit]].}}<br />
<br />
Slow startup times are often caused by one of two things.<br />
<br />
To determine which it might be, run Emacs with:<br />
<br />
$ emacs -q<br />
<br />
* Mistakes, particularly in /etc/hosts, will often result in a 5+ second delay when starting Emacs. Refer to '[[Configuring_network#Set_the_hostname|set the hostname]]' in the network configuration guide for information. <br />
<br />
* You may need to monitor any network packets sent from your computer (using a program like Wireshark) to see if there is any strange behavior.<br />
<br />
* A simple way to search for the cause is to comment-out (i.e., prefix lines with ';') suspect sections of your {{ic|~/.emacs}} (or {{ic|~/.emacs.d/init.el}}) then start Emacs again to see if there is any change. Keep in mind use of "require" and "load" can slow the startup down, especially when used with larger extensions. They should, as a rule, only be used when their target is either: needed once Emacs starts or provides little more than "autoloads" for an extension. Otherwise, use the 'autoload function directly. For example, instead of:<br />
<br />
(require 'anything)<br />
<br />
you might use:<br />
<br />
(autoload 'anything "anything" "Select anything" t)<br />
<br />
=== Cannot open load file: ... ===<br />
<br />
The most common cause of this error is the 'load-path' variable not including the path to the directory within which the extension is located. To solve this, add the appropriate path to the list to be searched prior to attempting to load the extension:<br />
<br />
(add-to-list 'load-path "/path/to/directory/")<br />
<br />
When attempting to use packages for extensions and Emacs has been configured with a prefix other than '/usr', the load-path will need to be updated. Place the following in {{ic|~/.emacs}} prior to the instructions provided by the package:<br />
<br />
(add-to-list 'load-path "/usr/share/emacs/site-lisp")<br />
<br />
If compiling Emacs by hand, keep in mind that the default prefix is '/usr/local'.<br />
<br />
=== Dead-accent keys problem: '<dead-acute> is undefined' ===<br />
<br />
Searching about this bug on Google, we find this link:<br />
http://lists.gnu.org/archive/html/help-gnu-emacs/2009-05/msg00167.html<br />
<br />
Explaining the problem: in recent versions of<br />
b72<br />
Emacs, the normal way to use accent keys does not work as expected. Trying to accent a word like 'fiancé' will produce the message above.<br />
<br />
A way to solve it is just put the line above on your startup file, {{ic|~/.emacs}}:<br />
<br />
(require 'iso-transl)<br />
<br />
And no, it is not a bug, but a feature of new Emacs versions. Reading the subsequent messages about it on the mail list, we found it (http://lists.gnu.org/archive/html/help-gnu-emacs/2009-05/msg00179.html):<br />
<br />
:''It seems that nothing is loaded automatically because there is a choice betwee iso-transl and iso-acc. Both seem to provide an input method with C-x 8 or Alt-<accent> prefix, but what you and I are doing is just pressing a dead key (^, ´, `, ~, ¨) for the accent and then another key to "compose" the accented character. And there is no Alt key used in this! And according to documentation it seems be appropriate for 8-bit encodings, so it should be pretty useless in UTF-8. I reported this bug when it was introduced, but the bug seems to be classified as a feature ... Maybe it's just because the file is auto-loaded though pretty useless. ''<br />
<br />
=== C-M-% and some other bindings do not work in emacs nox ===<br />
<br />
This is because terminals are more limited than Xorg. Some terminals may handle more bindings than other, though. Two solutions:<br />
* either use the graphical version,<br />
* or change the binding to a supported one.<br />
<br />
Example:<br />
{{hc|.emacs|<br />
(global-set-key (kbd "C-M-y") 'query-replace-regexp)<br />
}}<br />
<br />
=== Emacs client gets stuck when switching back to it ===<br />
<br />
If you are using Emacs daemon, then you should know that input is blocking. If one Emacs instance is in the minibuffer (after an '''M-x''' for instance), then all other instance will wait for it to finish. Press '''C-g''' to cancel any input to make sure this Emacs session is not blocking.<br />
<br />
=== Emacs-nox output gets messy ===<br />
<br />
When working in a terminal, the color, indentation, or anything related to the output might become crazy. This is (probably?) because Emacs was sent a special character at some point which may conflict with the current terminal.<br />
There is not much to be done but restarting emacs. If someone has a workaround or a more detailed explanation on the issue, feel free to contribute.<br />
<br />
Graphical Emacs does not suffer from this issue.<br />
<br />
=== Shift + Arrow keys not working in emacs within tmux ===<br />
<br />
Enable xterm-keys in your [[tmux]] configuration:<br />
<br />
{{hc|~/.tmux.conf|<br />
setw -g xterm-keys on<br />
}}<br />
<br />
Because this will break other key combinations, put the following in your emacs config.<br />
<br />
{{hc|~/.emacs|<br />
(defadvice terminal-init-screen<br />
;; The advice is named `tmux', and is run before `terminal-init-screen' runs.<br />
(before tmux activate)<br />
;; Docstring. This describes the advice and is made available inside emacs;<br />
;; for example when doing C-h f terminal-init-screen RET<br />
"Apply xterm keymap, allowing use of keys passed through tmux."<br />
;; This is the elisp code that is run before `terminal-init-screen'.<br />
(if (getenv "TMUX")<br />
(let ((map (copy-keymap xterm-function-map)))<br />
(set-keymap-parent map (keymap-parent input-decode-map))<br />
(set-keymap-parent input-decode-map map))))<br />
}}<br />
<br />
See [https://github.com/tmux/tmux/blob/master/FAQ#L242 tmux FAQ] for details.<br />
<br />
=== Improper window resizing in KDE ===<br />
<br />
{{Merge|KDE|Applicable to other applications}}<br />
<br />
KDE users may observe that the Emacs window does not resize properly, but rather, the resized portion<br />
is transparent and mouse clicks are sent to the underlying window. To correct this behavior, change<br />
KDE's GTK3 theme to something other than oxygen-gtk. For instance, use the Emacs theme which is included with {{Pkg|gtk3}}.<br />
<br />
To force Emacs to maximize completely in KDE, click the Emacs icon in the title bar, and select More Actions > Special Window Settings. Then in the "Size & Position" tab, select "Obey geometry restrictions", choose "Force" in the dropdown menu, and select "No" from the radio buttons on the right.<br />
<br />
== Alternatives ==<br />
<br />
There are numerous "smaller" implementations of Emacs. GNU/Emacs is probably the most popular. Some lightweight Emacs compatible alternatives will be listed here:<br />
<br />
=== mg ===<br />
<br />
'''mg''' (originally called MicroGnuEmacs) is a lightweight implementation of Emacs written in C.<br />
<br />
{{Pkg|mg}} is available in the [[official repositories]] and it is also possible to download its source from its upstream [http://homepage.boetes.org/software/mg/ page]. Beware '''mg''' has no UTF-8 support.<br />
<br />
=== zile ===<br />
<br />
According to the official web [https://www.gnu.org/software/zile/ page] "GNU Zile is a lightweight Emacs clone. '''Zile''' is short for "Zile Is Lossy Emacs". Zile has been written to be as similar as possible to Emacs; every Emacs user should feel at home.". Zile has no UTF-8 support.<br />
<br />
{{Pkg|zile}} can be found in the official repositories.<br />
<br />
The latest upstream tarballs can be found in official GNU [http://ftp.sh.cvut.cz/MIRRORS/gnu/pub/gnu/zile/ mirrors].{{Dead link|2017|06|02}}<br />
<br />
=== uemacs ===<br />
<br />
'''uemacs''' is a "Micro-emacs" version customized by Linus Torvalds . Available as {{AUR|uemacs-git}} in the [[AUR]].<br />
<br />
The latest (2005) tarball can be found [ftp://ftp.cs.helsinki.fi/pub/Software/Local/uEmacs-PK/ here].<br />
<br />
=== remacs ===<br />
<br />
'''remacs''' is a community-driven port of Emacs to Rust. Available as {{AUR|remacs-git}} in the [[AUR]].<br />
<br />
== See also ==<br />
<br />
* [http://www.gnu.org/software/emacs/ GNU Emacs home page]<br />
* [http://www.gnu.org/software/emacs/manual/emacs.html GNU Emacs manual]<br />
* [http://www.emacswiki.org/cgi-bin/wiki/ Emacs Wiki]{{Dead link|2017|06|02}}<br />
* [http://wikemacs.org WikEmacs - a more readable, but less complete Emacs wiki]<br />
* [http://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial.html Useful introduction to Emacs and its shortcuts]<br />
* [https://d0edfcdc0ccc1cd13cdab5eb986fb92e8660dbef.googledrive.com/host/0B6LMD0u8OhYYZEotN2QyR1hwR1k/ The Church of Emacs (via Google drive)]{{Dead link|2017|06|02}}<br />
* [http://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf Official reference card]</div>Titan-c