页面

显示标签为“emacs”的博文。显示所有博文
显示标签为“emacs”的博文。显示所有博文

2011-03-02

automatically read-only mode enabled after idle some time

Now add the following function to `.emacs', and then emacs can automatically toggle into read-only mode after idle some time:
;;; 128秒沉寂后自动转入只读模式
(setq timer_read-only (run-with-idle-timer 128 t 'toggle-read-only 1))

2010-07-21

eshell

history

The ‘history’ command shows all commands kept in the history ring as numbered list. If the history ring contains eshell-history-size commands, those numbers change after every command invocation, therefore the ‘history’ command shall be applied before using the expansion mechanism with history numbers.

The n-th entry of the history ring can be applied with the ‘!n’ command. If n is negative, the entry is counted from the end of the history ring.

‘!foo’ expands to the last command beginning with foo, and ‘!?foo’ to the last command containing foo. The n-th argument of the last command beginning with foo is accessible by !foo:n.

2010-02-22

emacs临时绑定一个elisp函数到某个键组合

(global-set-key (kbd "<f8>")
   (lambda() 
        (interactive)
        (save-buffer)
        (call-process-shell-command "latex -interact=batchmode -output-format=pdf assignment_2")
        (message "having generated pdf successfully")))
必须调用“interactive“函数。

2010-02-18

emacs画表时指定画表符号

Characters used to recognize/draw the borders of the table can be specified with the help of the following variables:

table-cell-horizontal-chars

Contains a string. All characters in string are valid horizontal delimiters for the table. The first character of the string is used for output.

table-cell-horizontal-char

Contains the character used as the vertical delimiter. “|” by default.

table-cell-intersection-char

Contains the character that appears at the intersection of rows and columns. “+” is the default.

The following settings give interesting results. They use utf-8 characters to draw continuous lines for the border of the table. Arguably, your font should support these character to display the desired effect.

(setq table-cell-horizontal-chars "\u2501")
(setq table-cell-vertical-char ?\u2503)
(setq table-cell-intersection-char ?\u254B)

2010-02-11

Use the Third Part elisp Package

Put some .el file to womewhere like `~/.elisp', and add .emacs with expressions like the following two lines:
(add-to-list 'load-path "~/.elisp")
(require 'foo)

2009-07-25

Alternate Default Debian Editor

The default editor in Debian is nano. User may change that:
$ update-alternatives --config editor

2009-04-11

emacs cheat sheet

  1. Bookmark:
    C-x r m
    C-x r b
  2. Uppercase initial:
    upcase-initials-region
  3. 搜索当前位置的单词:
    C-s C-w
  4. 搜索性质的高亮:
    C-s C-w C-w ...
  5. 复制矩形块区域(即列选择)
    C-x r r register_name
    C-x r i register_name
  6. 复制区域
    C-x r s register_name
    C-x r i register_name
  7. 删除矩形区
    M-x delete-rectangle
  8. 保存位置及返回(非书签方式)
    C-x r SPC register_name
    C-x r j register_name
  9. see manual for perfectly printing
  10. 高亮:
    C-x w h
    C-x w r
  11. Indent multiple lines (within a region):
    C-M-\
  12. Indent multiple lines (within a parenthesized programming expression block):
    C-M-q
  13. Resize current window (not the frame):
    C-x ^ # to make the current windows taller
    C-x { # to make it wider
  14. eshell mode operations:
    M-p # Fetch the next earlier old shell command.
    M-n # Fetch the next later old shell command.
    M-r regexp RET # Search backwards for old shell commands that match regexp.
    M-s regexp RET # Search forwards for old shell commands that match regexp.
    C-c C-x # Fetch the next subsequent command from the history.
  15. Reload file (which actually is a trick):
    C-x C-v RET
  16. Kill job in eshell mode:
    C-c C-k
  17. Validate XML:
    C-c C-v
    Maybe, an XML parser is required:
    $ aptitude install sp
  18. Show key-binding and help of current mode:
    C-h m
  19. Transpose text:
    C-t # 2 characters
    M-t # 2 words
    C-x C-t # 2 lines
  20. Temparorily key-binding to a script
    M-x local-set-key RET key RET command RET
  21. Highliting parenthesis
    M-x show-paren-mode
  22. Yanking to mini-buffer as searching
    C-s M-y
  23. Toggling buffer with read-only
    C-x C-q
  24. 折行:
    M-q
    C-x f # set column width
    M-x fill-region
    M-x fill-region-as-paragraph
    M-s # center a line
    M-x auto-fill-mode # automatic mode
    M-x set-fill-column # adjust column number for auto-fill-mode
  25. goto-line
    M-g g
  26. Show column number:
    M-x column-number-mode
  27. Completion:
    M-/