forked from sunrise-commander/sunrise-commander
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sunrise-x-old-checkpoints.el
93 lines (73 loc) · 3.8 KB
/
sunrise-x-old-checkpoints.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
;;; sunrise-x-old-checkpoints.el --- backward compatibility checkpoint functions for the Sunrise Commander File Manager
;; Copyright (C) 2009-2010 José Alfredo Romero Latouche.
;; Author: José Alfredo Romero L. <[email protected]>
;; Štěpán Němec <[email protected]>
;; Maintainer: José Alfredo Romero L. <[email protected]>
;; Created: 28 Dec 2009
;; Version: 1
;; RCS Version: $Rev: 374 $
;; Keywords: sunrise commander, old checkpoints
;; URL: http://www.emacswiki.org/emacs/sunrise-x-old-checkpoints.el
;; Compatibility: GNU Emacs 22
;; This file is *NOT* part of GNU Emacs.
;; This program is free software: you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free Software
;; Foundation, either version 3 of the License, or (at your option) any later
;; version.
;;
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more de-
;; tails.
;; You should have received a copy of the GNU General Public License along with
;; this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Beginning with version 4 of the Sunrise Commander, checkpoints were redefined
;; to be a special form of bookmarks. Unfortunately, creating bookmarks with
;; custom handlers isn't supported in the version of bookmarks.el distributed
;; with Emacs 22, so if you use Sunrise checkpoints and you don't want to update
;; your bookmarks.el, just add this extension to your .emacs.el to get back the
;; original functionality.
;; This is version 1 $Rev: 374 $ of the Old Checkpoints Extension.
;; It was written on GNU Emacs 23 on Linux, and tested on GNU Emacs 22 and 23
;; for Linux and on EmacsW32 (version 22) for Windows.
;;; Installation and Usage:
;; 1) Put this file somewhere in your Emacs `load-path'. (Optionally) compile
;; it.
;; 2) Enjoy ;-) -- Sunrise should pick the correct extension automatically. On
;; Emacs 23 it will look for sunrise-x-checkpoints, while on Emacs 22 it'll try
;; to load sunrise-x-old-checkpoints. Only if you *really* want to use the old
;; extensions with a more recent version of bookmarks.el than the one bundled
;; with Emacs 22 you may add a new (require 'sunrise-x-old-checkpoints) to your
;; .emacs file somewhere after (require 'sunrise-commander).
;;; Code:
(eval-when-compile (require 'sunrise-commander))
(defvar sr-checkpoint-registry '(("~" "~/" "~/"))
"Registry of currently defined checkpoints.")
(defun sr-checkpoint-save (&optional name)
"Save the current Sunrise pane directories under NAME for later restoring."
(interactive "sCheckpoint name to save? ")
(let ((my-cell (assoc-string name sr-checkpoint-registry)))
(sr-save-directories)
(if (null my-cell)
(setq sr-checkpoint-registry
(acons name
(list sr-left-directory sr-right-directory)
sr-checkpoint-registry))
(setcdr my-cell (list sr-left-directory sr-right-directory)))
(message "%s" (concat "Checkpoint \"" name "\" saved"))))
(defun sr-checkpoint-restore (&optional name)
"Restore a checkpoint previously saved under NAME."
(interactive "sCheckpoint name to restore? " )
(let* ((cp-list (assoc-string name sr-checkpoint-registry))
(dirs-list (cdr cp-list)))
(unless cp-list
(error (concat "No such checkpoint: " name)))
(if (eq sr-selected-window 'right)
(setq dirs-list (reverse dirs-list)))
(mapc (lambda (x) (sr-goto-dir x) (sr-change-window)) dirs-list)))
(defun sr-checkpoint-handler (&optional arg)
"Dummy function for compatilibity with the new checkpoints interface."
(ignore))
(provide 'sunrise-x-old-checkpoints)
;;; sunrise-x-old-checkpoints.el ends here