Gih's Blog

只言片语
Posts tagged as emacs

Move from Sr-SpeedBar to NeoTree

2014-09-17 by gihnius, tagged as emacs

NeoTree is more lightweight and simple.

;; (require 'sr-speedbar)
;; (make-face 'speedbar-face)
;; (set-face-font 'speedbar-face "DejaVu Sans Mono-11")
;; (setq speedbar-use-images nil)
;; (setq sr-speedbar-delete-windows t)
;; (setq sr-speedbar-right-side nil)
;; (setq sr-speedbar-width-x 25)
;; (setq sr-speedbar-width-console 25)
;; (setq sr-speedbar-max-width 30)
;; (setq speedbar-verbosity-level 0)
;; (setq sr-speedbar-skip-other-window-p t)

;; install neotree by ELPA
;; use neotree instead
(require 'neotree)
(setq neo-window-width 28)

how they looks?

create small emacs window

2014-09-08 by gihnius, tagged as emacs

create a small "mini pad" from emacs by make-frame function.

(defun make-mini-pad ()
  (interactive)
  (make-frame '(
                (name . "mini")
                (width . 72)
                (height . 39))))

M-x make-mini-pad


用guile重写emacs?

2011-09-07 by gihnius, tagged as emacs

在solidot 看到这个新闻, 关于前段的:GNU黑客大会2011 , 里面提到用 Guile 实现 Emacs .

Guile ? Scheme ? 写个 emacs ?我记得之前有新闻说 emacs 25 这个版本要用 common lisp 重写. 后来也发现一些 common lisp 做的非完整版本的 emacs 实现, 例如: climacs Hemlock 另外一些描述可以从这里看到:http://www.cliki.net/CL-Emacs现在怎么弄个 scheme 版本的? 我不是怀疑 scheme 不能写一个emacs, 我是觉得, 那些聪明人写了emacs之后, 会把scheme弄大吗? 会再来一个 浏览器, 播放器, 还有什么商业应用之类吗? 我希望他们会做, 然后再弄一个庞大的标准库, 然后: A Common Scheme Was Born!.Lisp社区有很多不稳定的因素, 严重分化阻碍了社区的健康发展. 看看 Paul Graham, common lisp玩得好好的, 却去弄个 Arc .

Quickly create empty buffer (scratch) in Emacs.

2011-06-27 by gihnius, tagged as emacs

By default when Emacs starts up, it contains a buffer named *scratch*, which is provided for evaluating Emacs Lisp expressions interactively. Its major mode is "Lisp Interaction mode". 

The “*scratch*” “buffer” is designed for emacs lisp programers. (it defaults to lisp-interaction-mode.) but 99% of emacs users are not lisp coders. 

If you want a scratch pad, how do you open a new(empty) document in Emacs? This way is familiar to all software users. Here is a elisp function to let you do this. It open one or more new buffers and set major to text-mode.

(defun new-empty-buffer ()
  (interactive)
  (let ((n 0)
        new-buf)
    (while (progn
             (setq new-buf (concat "-untitled-"
                                       (if (= n 0) "0" (int-to-string n))
                                       "-"))
             (incf n)
             (get-buffer new-buf)))
    (switch-to-buffer (get-buffer-create new-buf))
    (text-mode)))

You can change the major mode from the last line to yours, eg. lisp-mode, ruby-mode, html-mode.

Bind this function to Win + n or CMD + n, just like what we do in other softwares.

(global-set-key (kbd "s-n") 'new-empty-buffer)

Then, you can press ⌘+n to create an empty buffer named -untitled-0-, and the next will be -untitled-1-, -untitled-2- ... -untitled-N-.

emacs 重新绑定C-x C-c,避免一时手快退出

2011-06-01 by gihnius, tagged as emacs

emacs的按键序列又长又相似, 以前经常手快或无意按了 C-x C-c.

写了一个函数重新绑定 C-x C-c 的行为:

;; ...never quit by mistake...
(global-set-key [(control x) (control c)]
                (function
                 (lambda () (interactive)
                   (cond ((y-or-n-p "Relax...? ")
                          (if server-clients (server-edit)
                            (save-buffers-kill-emacs)))))))

如果按下C-x C-c, emacs会询问你是否 Relax ? 如果当前窗口是一个 client frame

就直接退出该 client.