diff options
author | William Xu <william.xwl@gmail.com> | 2008-06-17 14:43:45 +0900 |
---|---|---|
committer | William Xu <william.xwl@gmail.com> | 2008-06-17 14:43:45 +0900 |
commit | 67f5263943276faee0de53d947b6191205ae7a43 (patch) | |
tree | 0e67fe4722894a3d4dc9806fc506617c8a0c8a7d /emms-history.el | |
parent | 964d7c3b354b66d0fba6f4eb7c2e058c2bfe2d59 (diff) |
*.el -> lisp/*.el: Move lisp files into "lisp/" subdirectory.
Diffstat (limited to 'emms-history.el')
-rw-r--r-- | emms-history.el | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/emms-history.el b/emms-history.el deleted file mode 100644 index 47d2e73..0000000 --- a/emms-history.el +++ /dev/null @@ -1,125 +0,0 @@ -;;; emms-history.el -- save all playlists when exiting emacs - -;; Copyright (C) 2006, 2007 Free Software Foundation, Inc. -;; -;; Author: Ye Wenbin <wenbinye@163.com> - -;; This file is part of EMMS. - -;; 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, 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 details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program; if not, write to the Free Software -;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -;;; Commentary: - -;; Saves all playlists when you close emacs. When you start it up again use -;; M-x emms-history-load to restore all saved playlists. - -;; To use it put the following into your ~/.emacs: -;; -;; (require 'emms-history) -;; -;; If all playlists should be restored on startup add this, too: -;; -;; (emms-history-load) - -;;; Code: - -(require 'emms) -(eval-when-compile - (require 'cl)) - -(defgroup emms-history nil - "Saving and restoring all playlists when closing/restarting -Emacs." - :prefix "emms-history-" - :group 'emms) - -(defcustom emms-history-file (concat (file-name-as-directory emms-directory) "history") - "The file to save playlists in." - :type 'string - :group 'emms-history) - -(defcustom emms-history-start-playing nil - "If non-nil emms starts playing the current track after -`emms-history-load' was invoked." - :type 'boolean - :group 'emms-history) - -(defun emms-history-save () - "Save all playlists that are open in this Emacs session." - (interactive) - (when (stringp emms-history-file) - (let ((oldbuf emms-playlist-buffer) - ;; print with no limit - print-length print-level - emms-playlist-buffer playlists) - (save-excursion - (dolist (buf (emms-playlist-buffer-list)) - (set-buffer buf) - (when (> (buffer-size) 0) ; make sure there is track in the buffer - (setq emms-playlist-buffer buf - playlists - (cons - (list (buffer-name) - (or - (and emms-playlist-selected-marker - (marker-position emms-playlist-selected-marker)) - (point-min)) - (save-restriction - (widen) - (nreverse - (emms-playlist-tracks-in-region (point-min) - (point-max))))) - playlists)))) - (with-temp-buffer - (insert "(\n;; active playlist\n") - (prin1 (buffer-name oldbuf) (current-buffer)) - (insert "\n;; playlists: ((BUFFER_NAME SELECT_POSITION TRACKS) ...)\n") - (prin1 playlists (current-buffer)) - (insert "\n;; play method\n") - (prin1 `((emms-repeat-track . ,emms-repeat-track) - (emms-repeat-playlist . ,emms-repeat-playlist)) - (current-buffer)) - (insert "\n)") - (write-file emms-history-file)))))) - -(add-hook 'kill-emacs-hook 'emms-history-save) - -(defun emms-history-load () - "Restore all playlists in `emms-history-file'." - (interactive) - (when (and (stringp emms-history-file) - (file-exists-p emms-history-file)) - (let (history buf) - (with-temp-buffer - (insert-file-contents emms-history-file) - (setq history (read (current-buffer))) - (dolist (playlist (cadr history)) - (with-current-buffer (emms-playlist-new (car playlist)) - (setq emms-playlist-buffer (current-buffer)) - (if (string= (car playlist) (car history)) - (setq buf (current-buffer))) - (mapc 'emms-playlist-insert-track - (nth 2 playlist)) - (ignore-errors - (emms-playlist-select (cadr playlist))))) - (setq emms-playlist-buffer buf) - (dolist (method (nth 2 history)) - (set (car method) (cdr method))) - (ignore-errors - (when emms-history-start-playing - (emms-start))))))) - -(provide 'emms-history) -;;; emms-history.el ends here |