简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!
优质专栏:Audio工程师进阶系列【原创干货持续更新中……】🚀
人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.
1.前言
本篇目的:Emacs记录每个代码步骤,可以回退和前进,这样我们每一步都能在掌控之中,快速回退,这里不是代码回退,而是每个步骤可以回退。
2.安装步骤
<1>.源码
;;; Code:
(eval-when-compile (require 'cl))
(defvar point-undo-list nil)
(make-variable-buffer-local 'point-undo-list)
(defvar point-redo-list nil)
(make-variable-buffer-local 'point-redo-list)
(defun point-undo-pre-command-hook ()
"Save positions before command."
(unless (or (eq this-command 'point-undo)
(eq this-command 'point-redo))
(let ((cell (cons (point) (window-start))))
(unless (equal cell (car point-undo-list))
(setq point-undo-list (cons cell point-undo-list))))
(setq point-redo-list nil)))
(add-hook 'pre-command-hook 'point-undo-pre-command-hook)
(defun point-undo-doit (list1 list2)
;; list1, list2 = {point-undo-list, point-redo-list}
(destructuring-bind (pt . wst)
(or (car (symbol-value list1)) '(nil)) ;nil-safe
(when pt
(set list1 (cdr (symbol-value list1)))
(set list2 (cons (cons (point) (window-start)) (symbol-value list2)))
(goto-char pt)
(set-window-start (selected-window) wst))))
(defun point-undo ()
"Undo position."
(interactive)
(point-undo-doit 'point-undo-list 'point-redo-list))
(defun point-redo ()
"Redo position."
(interactive)
(when (or (eq last-command 'point-undo)
(eq last-command 'point-redo))
(point-undo-doit 'point-redo-list 'point-undo-list)))
;;;; Bug report
(defvar point-undo-maintainer-mail-address
(concat "rubiki" "tch@ru" "by-lang.org"))
(defvar point-undo-bug-report-salutation
"Describe bug below, using a precise recipe.
When I executed M-x ...
How to send a bug report:
1) Be sure to use the LATEST version of point-undo.el.
2) Enable debugger. M-x toggle-debug-on-error or (setq debug-on-error t)
3) Use Lisp version instead of compiled one: (load \"point-undo.el\")
4) If you got an error, please paste *Backtrace* buffer.
5) Type C-c C-c to send.
# If you are a Japanese, please write in Japanese:-)")
(defun point-undo-send-bug-report ()
(interactive)
(reporter-submit-bug-report
point-undo-maintainer-mail-address
"point-undo.el"
(apropos-internal "^point-undo-" 'boundp)
nil nil
point-undo-bug-report-salutation))
(provide 'point-undo)
;; How to save (DO NOT REMOVE!!)
;; (emacswiki-post "point-undo.el")
;;; point-undo.el ends here
<2>.配置
;;https://github.com/emacsmirror/point-undo
(load-file "~/.emacs.d/site-lisp/point-undo.el")
(require 'point-undo)
(global-set-key (kbd "o") 'point-undo)//回退
(global-set-key (kbd "p") 'point-redo)//前进