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