1142
|
1 |
.. -*- coding: utf-8; -*-
|
|
2 |
|
|
3 |
========
|
|
4 |
Emacs.
|
|
5 |
========
|
|
6 |
.. contents::
|
|
7 |
|
|
8 |
About.
|
|
9 |
======
|
|
10 |
|
|
11 |
http://elpa.gnu.org/
|
|
12 |
Packages for Emacs. This requires Emacs version 24.1 or
|
|
13 |
higher.
|
|
14 |
|
|
15 |
Getting help.
|
|
16 |
=============
|
|
17 |
|
|
18 |
* http://news.gmane.org/gmane.emacs.help
|
|
19 |
* http://news.gmane.org/gmane.emacs.announce
|
|
20 |
* http://news.gmane.org/gmane.emacs.auctex.announce
|
|
21 |
|
|
22 |
Installing Emacs.
|
|
23 |
=================
|
|
24 |
|
|
25 |
http://ftp.gnu.org/gnu/emacs/windows/
|
|
26 |
Clean GNU Emacs for 32-bit Windows
|
|
27 |
http://emacsformacosx.com/
|
|
28 |
Clean GNU Emacs for Mac OS X
|
|
29 |
|
|
30 |
Variables.
|
|
31 |
==========
|
|
32 |
|
|
33 |
Select one of::
|
|
34 |
|
|
35 |
(set 'variable value)
|
|
36 |
(setq variable value)
|
|
37 |
(defvar variable value "documentation")
|
|
38 |
|
|
39 |
or (replace <colon> with::
|
|
40 |
|
|
41 |
# Local variables<colon>
|
|
42 |
# variable<colon> value
|
|
43 |
# End<colon>
|
|
44 |
|
|
45 |
Debugging.
|
|
46 |
==========
|
|
47 |
|
|
48 |
Evaluating elisp expression on the fly.
|
|
49 |
---------------------------------------
|
|
50 |
|
|
51 |
Type M-: than lisp expression than type RET.
|
|
52 |
|
|
53 |
Or in any buffer place point at the end of lisp expression and type C-x C-e.
|
|
54 |
|
|
55 |
Or invoke elisp "shell" by M-x ielm.
|
|
56 |
|
|
57 |
What functions and variables Emacs load and from which files?
|
|
58 |
-------------------------------------------------------------
|
|
59 |
|
|
60 |
See value of variable ``load-history`` (by C-h v load-history RET).
|
|
61 |
|
|
62 |
Using edebug.
|
|
63 |
-------------
|
|
64 |
|
|
65 |
Execute ``M-x edebug-defun`` (also on ``C-u C-M-x``) on defun in source code to
|
|
66 |
enable debugging for desired function. When next time this function invoked
|
|
67 |
you entered to its debugging (jumped to its source code).
|
|
68 |
|
|
69 |
To start debug execute code which used debugged function.
|
|
70 |
|
|
71 |
You can disable edebug on a function by evaluating the function again using
|
|
72 |
``C-M-x``.
|
|
73 |
|
|
74 |
How debug func?
|
|
75 |
---------------
|
|
76 |
|
|
77 |
Use M-x debug-on-entry and M-x cancel-debug-on-entry to control
|
|
78 |
which functions will enter the debugger when called.
|
|
79 |
|
|
80 |
When next time that function called automatically loaded debug-mode.
|
|
81 |
|
|
82 |
How debug ini file?
|
|
83 |
-------------------
|
|
84 |
|
|
85 |
When your ini has a bug, or when you load external files that cause
|
|
86 |
errors, the bug is often hard to find, because the Emacs Lisp reader does not
|
|
87 |
know about line numbers and files - it just knows an error happened, and
|
|
88 |
that's it.
|
|
89 |
|
|
90 |
Try run Emacs with ``--debug-init`` to see backtrace.
|
|
91 |
|
|
92 |
How debug long running command?
|
|
93 |
-------------------------------
|
|
94 |
|
|
95 |
M-x debug-on-quit RET`` and then just hit `C-g`` next time it gets ``stuck``
|
|
96 |
somewhere.
|
|
97 |
|
|
98 |
Check if bug in ini file not in Emacs itself.
|
|
99 |
---------------------------------------------
|
|
100 |
|
|
101 |
First run Emacs without loading anything::
|
|
102 |
|
|
103 |
$ emacs --no-init-file --no-site-file
|
|
104 |
|
|
105 |
or more shortly (as ``-Q`` imply ``-q``, ``--no-site-file``, and ``--no-splash``
|
|
106 |
together)::
|
|
107 |
|
|
108 |
$ emacs -Q
|
|
109 |
|
|
110 |
If bug not reproduced bug lies in ini files!
|
|
111 |
|
|
112 |
Debug by binary search.
|
|
113 |
-----------------------
|
|
114 |
|
|
115 |
Select half of the file in a region, and M-x eval-region. Depending on whether
|
|
116 |
that causes the error or not, split this half or the other half again, and
|
|
117 |
repeat.
|
|
118 |
|
|
119 |
Simplified Binary Search.
|
|
120 |
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
121 |
|
|
122 |
Add (error ``No error until here``) in the middle of your file. If you get the
|
|
123 |
error ``No error until here`` when reloading the file, move the expression
|
|
124 |
towards the back of the file, otherwise towards the front of the file.
|
|
125 |
|
|
126 |
Elisp debug tips.
|
|
127 |
-----------------
|
|
128 |
|
|
129 |
- Use a keyboard macro that moves forward one expression (sexp) and evaluates
|
|
130 |
it.
|
|
131 |
- Try C-x check-parens.
|
|
132 |
|
|
133 |
Enable debug mode (also on loading).
|
|
134 |
------------------------------------
|
|
135 |
|
|
136 |
Set in source::
|
|
137 |
|
|
138 |
(setq debug-on-error t)
|
|
139 |
|
|
140 |
or invoke Emacs like::
|
|
141 |
|
|
142 |
$ emacs --debug-init
|
|
143 |
|
|
144 |
where ``--debug-init`` binds ``debug-on-error`` to ``t`` while loading the init
|
|
145 |
file, and bypasses the ``condition-case`` which normally catches errors in the
|
|
146 |
init file.
|
|
147 |
|
|
148 |
Call tree.
|
|
149 |
----------
|
|
150 |
|
|
151 |
Before byte compiling file execute::
|
|
152 |
|
|
153 |
(setq byte-compile-generate-call-tree t)
|
|
154 |
|
|
155 |
Veiw buffer local variables.
|
|
156 |
----------------------------
|
|
157 |
::
|
|
158 |
|
|
159 |
(pp (buffer-local-variables))
|
|
160 |
|
|
161 |
Emacs profiling.
|
|
162 |
================
|
|
163 |
|
|
164 |
benchmark.el.
|
|
165 |
-------------
|
|
166 |
::
|
|
167 |
|
|
168 |
(benchmark-run 1 (revert-buffer))
|
|
169 |
|
|
170 |
elp.el.
|
|
171 |
-------
|
|
172 |
|
|
173 |
Enter a prefix for ``M-x elp-instrument-package``, perform action and see result
|
|
174 |
by ``M-x elp-results``. To perform new measurement don't forget to run
|
|
175 |
``M-x elp-reset-all``.
|
|
176 |
|
|
177 |
WWW.
|
|
178 |
====
|
|
179 |
|
|
180 |
Text based WWW browser.
|
|
181 |
-----------------------
|
|
182 |
|
|
183 |
http://en.wikipedia.org/wiki/W3m
|
|
184 |
http://emacs-w3m.namazu.org/
|
|
185 |
http://www.gnu.org/software/w3/
|
|
186 |
|
|
187 |
Tricks.
|
|
188 |
=======
|
|
189 |
|
|
190 |
Sort and uniquify lines.
|
|
191 |
------------------------
|
|
192 |
|
|
193 |
Select region, type ``C-u M-| sort -u RET``.
|
|
194 |
|
|
195 |
With transient-mark-mode and delete-selection-mode enabled: select region,
|
|
196 |
type M-| sort -u RET to replace selection with sorted and uniquified lines.
|
|
197 |
|
|
198 |
Determining running environment/platform.
|
|
199 |
=========================================
|
|
200 |
|
|
201 |
Check variables::
|
|
202 |
|
|
203 |
emacs-major-version
|
|
204 |
emacs-minor-version
|
|
205 |
window-system - ``nil`` if in terminal, ``w32`` if native Windows build, ``x`` if under X Window
|
|
206 |
window-system-version - for windows only
|
|
207 |
window-size-fixed
|
|
208 |
operating-system-release - release of the operating system Emacs is running on
|
|
209 |
system-configuration - like configuration triplet: cpu-manufacturer-os
|
|
210 |
system-configuration-options
|
|
211 |
system-name - host name of the machine you are running on
|
|
212 |
system-time-locale
|
|
213 |
system-type - indicating the type of operating system you are using:
|
|
214 |
``gnu`` (GNU Hurd),
|
|
215 |
``gnu/linux``,
|
|
216 |
``gnu/kfreebsd``, ``berkeley-unix`` for (FreeBSD),
|
|
217 |
``darwin`` (GNU-Darwin, Mac OS X),
|
|
218 |
``ms-dos``,
|
|
219 |
``windows-nt``,
|
|
220 |
``cygwin``
|
|
221 |
system-uses-terminfo
|
|
222 |
dynamic-library-alist or deprecated image-library-alist
|
|
223 |
- alist of image types vs external libraries needed to display them
|
|
224 |
|
|
225 |
and check functions::
|
|
226 |
|
|
227 |
(fboundp ...) - return t if SYMBOL's function definition is not void
|
|
228 |
(featurep ...) - returns t if FEATURE is present in this Emacs
|
|
229 |
(display-graphic-p) - return non-nil if DISPLAY is a graphic display; graphical
|
|
230 |
displays are those which are capable of displaying several
|
|
231 |
frames and several different fonts at once
|
|
232 |
(display-multi-font-p) - same as ``display-graphic-p``
|
|
233 |
(display-multi-frame-p) - same as ``display-graphic-p``
|
|
234 |
(display-color-p) - return t if DISPLAY supports color
|
|
235 |
(display-images-p) - return non-nil if DISPLAY can display images
|
|
236 |
(display-grayscale-p) - return non-nil if frames on DISPLAY can display shades of gray
|
|
237 |
(display-mouse-p) - return non-nil if DISPLAY has a mouse available
|
|
238 |
(display-popup-menus-p) - return non-nil if popup menus are supported on DISPLAY
|
|
239 |
(display-selections-p) - return non-nil if DISPLAY supports selections
|
|
240 |
|
|
241 |
Run those checks as below::
|
|
242 |
|
|
243 |
(when window-system ...)
|
|
244 |
(when (eq window-system 'x) ...)
|
|
245 |
(when (>= emacs-major-version 22) ...)
|
|
246 |
(when (fboundp '...) ...)
|
|
247 |
(when (featurep '...) ...)
|
|
248 |
|
|
249 |
Compiling emacs.
|
|
250 |
================
|
|
251 |
|
|
252 |
Windows.
|
|
253 |
--------
|
|
254 |
|
|
255 |
Get MSYS for POSIX shell and utilities . Get MinGW for GCC. Get Gnuwin32 for
|
|
256 |
jpeg, ungif, tiff, xpm, png, zlib libraries.
|
|
257 |
|
|
258 |
Read emacs/nt/INSTALL::
|
|
259 |
|
|
260 |
$ cmd
|
|
261 |
$ cd emacs\nt
|
|
262 |
$ configure.bat --prefix %INST_ROOT% --with-gcc --cflags -I%GNUWIN32_ROOT%/include --ldflags -L%GNUWIN32_ROOT%/lib --ldflags -lregex
|
|
263 |
$ make bootstrap
|
|
264 |
$ make info
|
|
265 |
$ make install
|
|
266 |
|
|
267 |
Documentation.
|
|
268 |
==============
|
|
269 |
|
|
270 |
Elisp documentation.
|
|
271 |
--------------------
|
|
272 |
::
|
|
273 |
|
|
274 |
;;; <file-name>.el --- <one-line-description>
|
|
275 |
|
|
276 |
;; Copyright (C) <years> <person>
|
|
277 |
|
|
278 |
;; Author: <person> <mail>
|
|
279 |
;; Maintainer: <person> <mail>
|
|
280 |
;; Created: <date>
|
|
281 |
;; Version: <version>
|
|
282 |
;; Keywords: <look for ``finder-by-keyword`` output, separate by comma>
|
|
283 |
;; URL: <file-location>
|
|
284 |
|
|
285 |
;;; Commentary:
|
|
286 |
<bla-bla-bla>
|
|
287 |
;;; Code:
|
|
288 |
<lisp-code>
|
|
289 |
;;; <file-name> ends here
|
|
290 |
|
|
291 |
See
|
|
292 |
|
|
293 |
* http://www.gnu.org/software/emacs/elisp-manual/html_node/Library-Headers.html
|
|
294 |
* http://www.emacswiki.org/cgi-bin/wiki/ElispAreaConventions
|
|
295 |
|
|
296 |
CheckDoc.
|
|
297 |
---------
|
|
298 |
|
|
299 |
CheckDoc checks your EmacsLisp code for errors in documentation and style.
|
|
300 |
|
|
301 |
http://cedet.sourceforge.net/checkdoc.shtml
|
|
302 |
home page before including it into GNU Emacs
|
|
303 |
http://www.emacswiki.org/emacs/CheckDoc
|
|
304 |
CheckDoc
|
|
305 |
|
|
306 |
Installing Emacs.
|
|
307 |
=================
|
|
308 |
|
|
309 |
From sources.
|
|
310 |
-------------
|
|
311 |
|
|
312 |
http://ftp.gnu.org/pub/gnu/emacs
|
|
313 |
|
|
314 |
Windows.
|
|
315 |
--------
|
|
316 |
|
|
317 |
http://ftp.gnu.org/pub/gnu/emacs/windows
|
|
318 |
Releases for Windows.
|
|
319 |
http://alpha.gnu.org/gnu/emacs/windows
|
|
320 |
Beta releases for Windows.
|
|
321 |
|
|
322 |
Debian.
|
|
323 |
-------
|
|
324 |
::
|
|
325 |
|
|
326 |
$ apt-get install emacs
|
|
327 |
|
|
328 |
Emacs paths.
|
|
329 |
============
|
|
330 |
::
|
|
331 |
|
|
332 |
source-directory data-directory doc-directory exec-directory
|
|
333 |
invocation-directory trash-directory tutorial-directory user-emacs-directory
|
|
334 |
widget-image-directory
|
|
335 |
|
|
336 |
Emacs games.
|
|
337 |
============
|
|
338 |
::
|
|
339 |
|
|
340 |
hanoi hanoi-unix life pong tetris gomoku
|
|
341 |
|
|
342 |
Long lines.
|
|
343 |
===========
|
|
344 |
|
|
345 |
(setq longlines-show-hard-newlines t)
|
|
346 |
(setq longlines-wrap-follows-window-size t)
|
|
347 |
(longlines-mode 1)
|
|
348 |
|
|
349 |
Printing Emacs structures.
|
|
350 |
==========================
|
|
351 |
|
|
352 |
(message "%S" '(a b 123 "hello" 'set))
|
|
353 |
(pp '(a b 123 "hello" 'set))
|
|
354 |
(prin1-to-string '(1 2))
|
|
355 |
|
|
356 |
(symbol-name 'f)
|
|
357 |
(symbol-value 'f)
|
|
358 |
(symbol-function 'f)
|
|
359 |
(symbol-plist 'f)
|
|
360 |
|
|
361 |
File manager.
|
|
362 |
=============
|
|
363 |
|
|
364 |
http://www.emacswiki.org/emacs/Sunrise_Commander
|
|
365 |
|
|
366 |
Semantic.
|
|
367 |
=========
|
|
368 |
|
|
369 |
semantic-lex-spp-describe
|
|
370 |
Describe the current list of spp macros.
|
|
371 |
semantic-lex-c-preprocessor-symbol-file
|
|
372 |
List of C/C++ files that contain preprocessor macros for the C lexer.
|
|
373 |
|
|
374 |
Debugging C code.
|
|
375 |
=================
|
|
376 |
|
|
377 |
-*- mode: grep; mode: auto-revert-tail; default-directory: "~/devel/proj" -*-
|
|
378 |
|
|
379 |
XML modes.
|
|
380 |
==========
|
|
381 |
|
|
382 |
XSLT-process.
|
|
383 |
-------------
|
|
384 |
|
|
385 |
XSLT-process is a minor mode for GNU Emacs/XEmacs which transforms it into a powerful editor with
|
|
386 |
XSLT processing and debugging capabilities.
|
|
387 |
|
|
388 |
The mode currently supports two Java XSLT processors:
|
|
389 |
|
|
390 |
* Saxon - fully supported, including debugging capabilities.
|
|
391 |
* Xalan - fully supported, including debugging capabilities.
|
|
392 |
|
|
393 |
http://xslt-process.sourceforge.net/
|
|
394 |
home page
|
|
395 |
|
|
396 |
Useful program logging.
|
|
397 |
=======================
|
|
398 |
|
|
399 |
Put first line to your log file, you must replace ``default-directory`` to dir where you build
|
|
400 |
program::
|
|
401 |
|
|
402 |
-*- mode: compilation-minor; mode: auto-revert-tail; default-directory: "~/devel/proj" -*-
|
|
403 |
|
|
404 |
Program must use one of supported by ``compilation-minor-mode`` (see
|
|
405 |
``compilation-error-regexp-alist``), like::
|
|
406 |
|
|
407 |
printf(__FILE__ ":%d: %s\n", __LINE__, msg); /* msg - user defined string */
|
|
408 |
|
|
409 |
or in second form (in this case line number included in format string, so easy searchable in
|
|
410 |
debugger)::
|
|
411 |
|
|
412 |
#define NUM2STR(x) STR(x)
|
|
413 |
#define STR(x) #x
|
|
414 |
|
|
415 |
printf(__FILE__ ":" NUM2STR(__LINE__) ": %s\n", msg);
|
|
416 |
|
|
417 |
Or some faster use ``grep-mode``, but you restricted with GNU like error format::
|
|
418 |
|
|
419 |
-*- mode: grep; mode: auto-revert-tail; default-directory: "~/devel/proj" -*-
|
|
420 |
|
|
421 |
Edit HTML.
|
|
422 |
==========
|
|
423 |
|
|
424 |
* psgml-mode
|
|
425 |
* nxml-mode
|
|
426 |
* sgml-mode
|
|
427 |
|
|
428 |
html-helper-mode.
|
|
429 |
-----------------
|
|
430 |
|
|
431 |
Highlighting, autocompletion, and auto-insertion of closing tags.
|
|
432 |
|
|
433 |
http://www.emacswiki.org/emacs/HtmlHelperMode
|
|
434 |
http://savannah.nongnu.org/projects/baol-hth/
|
|
435 |
http://www.nongnu.org/baol-hth/
|
|
436 |
|
|
437 |
Source.
|
|
438 |
=======
|
|
439 |
|
|
440 |
Get main development sources::
|
|
441 |
|
|
442 |
$ bzr init-repo --2a emacs
|
|
443 |
$ cd emacs
|
|
444 |
$ bzr branch http://bzr.savannah.gnu.org/r/emacs/trunk trunk
|
|
445 |
$ cd trunk
|
|
446 |
$ bzr bind http://bzr.savannah.gnu.org/r/emacs/trunk
|
|
447 |
|
|
448 |
To update with latest changes::
|
|
449 |
|
|
450 |
$ cd emacs/trunk
|
|
451 |
$ bzr update
|
|
452 |
|
|
453 |
See:
|
|
454 |
|
|
455 |
http://www.emacswiki.org/emacs/BzrForEmacsDevs
|
|
456 |
|
|
457 |
Emacs Git mirror.
|
|
458 |
-----------------
|
|
459 |
|
|
460 |
http://www.emacswiki.org/emacs/EmacsFromGit
|
|
461 |
|
|
462 |
Patch.
|
|
463 |
======
|
|
464 |
|
|
465 |
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5719
|
|
466 |
[patch] fix bat-generic-mode highlighting pattern for CLI
|
|
467 |
switch.
|
|
468 |
|
|
469 |
How report bug.
|
|
470 |
===============
|
|
471 |
|
|
472 |
Visit http://debbugs.gnu.org or M-x report-emacs-bug.
|
|
473 |
|
|
474 |
|
|
475 |
Finding emacs packages.
|
|
476 |
=======================
|
|
477 |
|
|
478 |
* http://anc.ed.ac.uk/~stephen/emacs/ell.html
|
|
479 |
* http://www.emacswiki.org/emacs/WikifiedEmacsLispList
|
|
480 |
* http://www.emacswiki.org/emacs/RationalElispPackaging
|
|
481 |
|
|
482 |
http://tromey.com/elpa/index.html
|
|
483 |
Emacs Lisp Package Archive
|
|
484 |
|
|
485 |
|
|
486 |
EPLA.
|
|
487 |
-----
|
|
488 |
|
|
489 |
ELPA goal is to make it simple to install, use, and upgrade Emacs Lisp packages.
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
Currently (2011-02-15) available such sources::
|
|
494 |
|
|
495 |
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
|
|
496 |
("gnu" . "http://elpa.gnu.org/packages/")
|
|
497 |
("marmalade" . "http://marmalade-repo.org/packages/")
|
|
498 |
))
|
|
499 |
|
|
500 |
* http://www.emacswiki.org/emacs/ELPA
|
|
501 |
* http://marmalade-repo.org/
|
|
502 |
|
|
503 |
http://elpa.gnu.org/
|
|
504 |
official GNU Emacs Lisp Package Archive
|
|
505 |
http://tromey.com/elpa/
|
|
506 |
old Emacs Lisp Package Archive home page
|
|
507 |
http://tromey.com/elpa/upload.html
|
|
508 |
how to contribute
|
|
509 |
|
|
510 |
Emacswiki.
|
|
511 |
----------
|
|
512 |
|
|
513 |
http://www.emacswiki.org/emacs/ElispArea
|
|
514 |
http://www.emacswiki.org/emacs/WikifiedEmacsLispList
|
|
515 |
|
|
516 |
emacsmirror.
|
|
517 |
------------
|
|
518 |
|
|
519 |
https://github.com/emacsmirror/p/wiki
|
|
520 |
http://www.emacsmirror.org/
|
|
521 |
http://www.emacswiki.org/emacs/Emacsmirror
|
|
522 |
|
|
523 |
Funny Emacs modes.
|
|
524 |
==================
|
|
525 |
|
|
526 |
glasses
|
|
527 |
Minor mode for making identifiers likeThis readable.
|
|
528 |
|
|
529 |
Useful commands.
|
|
530 |
================
|
|
531 |
::
|
|
532 |
|
|
533 |
flush-lines keep-lines
|
|
534 |
align-regexp
|
|
535 |
C-x C-o
|
|
536 |
M-PageUp/M-PageDown
|
|
537 |
command-history
|
|
538 |
M-=
|
|
539 |
C-x l
|
|
540 |
locate-library find-library
|
|
541 |
features load-history
|
|
542 |
|