history
history copied to clipboard
Emacs - History utility for source code navigation.
history.el - History Utility For Code Navigation
This tool is similar to pop-global-mark but more powerful.
You can go through the whole history without losing them. Actually, pop-global-mark will use the latest record but also discard it. But this tool will preserve all the history and smartly ignore killed buffers or invalid symbol string.
You'll feel the power and convenience of using history-add-history, history-prev-history and history-next-history instead of built-in old way.
Demo

Basic Concept - Linked List Liked
- Normal history database:
(1) - (2) - (3) - (4) - (5)
^ index
- Goto previous Nth history:
(1) - (2) - (3) - (4) - (5)
^ index
- Add a new history into the database:
(1) - (2) - (3) - (new)
^ index
histories behind index will be discard,
and new one will be appended to the end.
Usage - First Step, Enable history-mode

-
(history-add-history)Save current point and buffer as a history into the database. -
(history-add-history t)Like above, but also save symbol string at point. When navigating to the history, the tool compare the matched string so that it makes sure the history is VALID. -
M-xhistory-prev-historyGoto previous history. -
M-xhistory-next-historyGoto new history. -
M-xhistory-kill-historiesDiscard whole history database. -
M-xhistory-goto-historyEnter history preview mode.ENTERto confirm to use the selected history.ESCto cancel preview and restore everything.

Advanced Usage
- Configure
history-advised-before-functionsandhistory-advised-after-functionsto add history automatically for you.
Example:
;; Add history just before `find-tag' executed.
(add-to-list 'history-advised-before-functions 'find-tag-noselect t)
;; Add history just before `find-file' executed.
(add-to-list 'history-advised-before-functions 'find-file-noselect t)
Advise primitive functions might cause infinite loop, strongly suggest you NOT to advise them.
Customization
-
history-history-maxThe maximum length of the history database. -
history-ignore-buffer-namesA REGEXP list to ignore specific buffers. -
history-window-local-historyTo toggle using window-local or global history. Window-local history means every window has its independent history database.

history-advised-before-functionsandhistory-advised-after-functions, a functions list to be advised to callhistory-add-history.

Contribution
Forks and pull requests are welcome!