[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emms-patches] darcs patch: Very basic support for recording the time yo
From: |
lucas |
Subject: |
[Emms-patches] darcs patch: Very basic support for recording the time you last pla... |
Date: |
Wed, 7 Jun 2006 19:28:57 +0200 (CEST) |
Wed Jun 7 19:28:30 CEST 2006 address@hidden
* Very basic support for recording the time you last played a track.
* emms-last-played.el: New file.
Nothing fancy right now, more to come soon.
* emms-setup.el: emms-devel now requires and setups emms-last-played.
New patches:
[Very basic support for recording the time you last played a track.
address@hidden
* emms-last-played.el: New file.
Nothing fancy right now, more to come soon.
* emms-setup.el: emms-devel now requires and setups emms-last-played.
] {
addfile ./emms-last-played.el
hunk ./emms-last-played.el 1
+;;; emms-last-played.el --- Support for last-played-time of a track
+
+;; Copyright (C) 2006 Lucas Bonnet <address@hidden>
+
+;; Author: Lucas Bonnet <address@hidden>
+;; Keywords: emms, mp3, mpeg, multimedia
+
+;; This file 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 2, or (at your option)
+;; any later version.
+
+;; This file 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 GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; Records when the track was last played.
+;; Big portions of the time handling fuctions are copied from
+;; gnus-util.el, and slightly adapted.
+
+;;; Code:
+
+(require 'emms)
+
+(defvar emms-last-played-format-alist
+ '(((emms-last-played-seconds-today) . "%k:%M")
+ (604800 . "%a %k:%M") ;;that's one week
+ ((emms-last-played-seconds-month) . "%a %d")
+ ((emms-last-played-seconds-year) . "%b %d")
+ (t . "%b %d '%y")) ;;this one is used when no
+ ;;other does match
+ "Specifies date format depending on when a track was last played.
+This is an alist of items (AGE . FORMAT). AGE can be a number (of
+seconds) or a Lisp expression evaluating to a number. When the age of
+the track is less than this number, then use `format-time-string'
+with the corresponding FORMAT for displaying the date of the track.
+If AGE is not a number or a Lisp expression evaluating to a
+non-number, then the corresponding FORMAT is used as a default value.
+
+Note that the list is processed from the beginning, so it should be
+sorted by ascending AGE. Also note that items following the first
+non-number AGE will be ignored.
+
+You can use the functions `emms-last-played-seconds-today',
+`emms-last-played-seconds-month' and
+`emms-last-played-seconds-year' in the AGE spec. They return the
+number of seconds passed since the start of today, of this month,
+of this year, respectively.")
+
+
+(defun emms-last-played-update-track (track)
+ "Updates the last-played time of TRACK."
+ (emms-track-set track 'last-played (current-time)))
+
+(defun emms-last-played-update-current ()
+ "Updates the current track."
+ (emms-last-played-update-track (emms-playlist-current-selected-track)))
+
+(defun emms-last-played-seconds-today ()
+ "Return the number of seconds passed today."
+ (let ((now (decode-time (current-time))))
+ (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600))))
+
+(defun emms-last-played-seconds-month ()
+ "Return the number of seconds passed this month."
+ (let ((now (decode-time (current-time))))
+ (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)
+ (* (- (car (nthcdr 3 now)) 1) 3600 24))))
+
+(defun emms-last-played-seconds-year ()
+ "Return the number of seconds passed this year."
+ (let ((now (decode-time (current-time)))
+ (days (format-time-string "%j" (current-time))))
+ (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)
+ (* (- (string-to-number days) 1) 3600 24))))
+
+(defun emms-last-played-format-date (messy-date)
+ "Format the messy-date according to emms-last-played-format-alist.
+Returns \" ? \" if there's bad input or if an other error occurs.
+Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
+ (condition-case ()
+ (let* ((messy-date (time-to-seconds messy-date))
+ (now (time-to-seconds (current-time)))
+ ;;If we don't find something suitable we'll use this one
+ (my-format "%b %d '%y"))
+ (let* ((difference (- now messy-date))
+ (templist emms-last-played-format-alist)
+ (top (eval (caar templist))))
+ (while (if (numberp top) (< top difference) (not top))
+ (progn
+ (setq templist (cdr templist))
+ (setq top (eval (caar templist)))))
+ (if (stringp (cdr (car templist)))
+ (setq my-format (cdr (car templist)))))
+ (format-time-string (eval my-format) (seconds-to-time messy-date)))
+ (error "Never.")))
+
+(provide 'emms-last-played)
+;;; emms-last-played.el ends here
hunk ./emms-setup.el 124
- (require 'emms-score))
+ (require 'emms-score)
+ (require 'emms-last-played)
+ ;; setup
+ (add-hook 'emms-player-started-hook 'emms-last-played-update-current))
+
}
Context:
[Mark the cache as dirty for each modification.
address@hidden
[emms.el: The currently playing marker now should stay where it is, even for
yanks
address@hidden
[emms-playlist-mode: Stop overlay from being attached to text inserted before it
address@hidden
[fix damien elmes's email address
Damien Elmes <address@hidden>**20060607154000]
[emms sources now switch add/play behavior when a prefix argument is supplied.
address@hidden
[Add autoloads to emms-setup.el
address@hidden
[Typo, defvar => defcustom for emms-cache-set-function
address@hidden
[Cleaned up the cached code in emms.el a bit
address@hidden
[refactor caching code into emms-cache.el
Damien Elmes <address@hidden>**20060607125345
* caching support is now provided via two function vars in emms.el,
emms-cache-get-function and emms-cache-set-function
* (emms-standard) or above will enable caching support
* you'll need to remove .emms-cache or s/emms-info-cache/emms-cache-db/
]
[emms-info: Fix bug that occurs after clearing the current playlist and trying
to re-add songs to it.
Michael Olson <address@hidden>**20060606144439]
[emms-playlist-mode doesn't need overlay compatibility anymore
address@hidden
[emms-playlist-mode.el - now with less overlay!
address@hidden
[AUTHORS: fixed Lucas' e-mail address
address@hidden
[info-cache-dirty/coding
Damien Elmes <address@hidden>**20060605163339
* mark the info cache as dirty when it's modified, so we don't have to
write it out all the time
* save the cache as mule-utf-8 - comments? i'm not sure if this is
correct
]
[AUTHORS: Damien Elmes address updated
address@hidden
[emms-info caching (thanks to Damien Elmes)
address@hidden
[Sort file names from `emms-source-file-directory-tree-function'.
address@hidden
[Add some sources for inserting playlists without inserting their contents, and
likewise for directories of playlist files. Exclude some files and directories
from being added when walking directories.
Michael Olson <address@hidden>**20060604195602]
[emms-player-mpd: Differentiate between files and URLs when it makes sense to
do so.
Michael Olson <address@hidden>**20060604195449]
[Miscellaneous minor cleanups.
Michael Olson <address@hidden>**20060604195311]
[Make sure we never have an empty track description when inserting a song into
a playlist buffer.
Michael Olson <address@hidden>**20060604194940]
[Remove debian-extras package as requested by ftpmasters (debian)
address@hidden
[Put volume options in their own customize group.
Martin Schoenmakers <address@hidden>**20060601193853
Added a separate emms-volume group for customize and put things there instead
of in the main thing.
]
[Make handling of multiple playlist buffers less error-prone.
Michael Olson <address@hidden>**20060531203810]
[emms-volume.el: Cosmetic stuff, defvar -> defcustom
address@hidden
[emms-volume.el: Minor cosmetic cleanup
address@hidden
[emms-volme.el: Add some requires.
address@hidden
[emms-volume-amixer.el: Provide a way to set the control for amixer
address@hidden
[AUTHORS: Add Martin Schoenmakers. Welcome! :-)
address@hidden
[Add emms-volume and emms-volume-amixer.
Martin Schoenmakers <address@hidden>**20060530223500
New files: emms-volume.el provides some general volume changing things,
including a minor mode to more easily change volume when not in the
EMMS buffer. emms-volume-amixer.el is a backend using amixer.
]
[emms-streams: Re-add space after prompt and use completion for type.
Michael Olson <address@hidden>**20060530190620]
[emms-streams: When the user wants emms-streams to play the selected stream
instead of add it, create our own playlist buffer. When quitting, if we own
the current playlist buffer, kill it.
Michael Olson <address@hidden>**20060530144243]
[allow nonzero ogginfo exit plus some reindenting
Martin Schoenmakers <address@hidden>**20060530130411
When ogginfo gave a nonzero value on exit, any valid data would get tossed
if there was any. This prevented emms from showing info for files that are
tagged but a bit odd.
Also reindented emms-info-ogginfo accordingly, which incidentally removed
some tabs in favour of spaces.
]
[emms-streams: Re-implement yank and kill so that they do the right thing with
emms-stream-list.
Michael Olson <address@hidden>**20060530045429]
[emms-streams: Implement kill and yank.
Michael Olson <address@hidden>**20060530040114]
[emms-streams: Make hitting RET on a URL do the right thing, improve cursor
movement, and mark the buffer as unmodified after performing a save.
Michael Olson <address@hidden>**20060529030043]
[emms-player-mpd: Make seek work correctly.
Michael Olson <address@hidden>**20060525033120]
[emms-player-mpd: Use more robust method of detecting whether we need to
force-feed MusicPD our playlist.
Michael Olson <address@hidden>**20060525014253]
[emms-playlist-mode: Make "d" kill the entire line. This seems to be a good
compromise of those who use C-k and those who want more standard object-killing
behavior.
foo**20060524200008]
[emms-player-mpd: When showing the currently-playing song, prepend the name of
the radio station, if it exists.
foo**20060524195911]
[emms-player-mpd: Fix bug that caused unconditional reloading of the entire
MusicPD playlist whenever the track was changed manually.
Michael Olson <address@hidden>**20060524061655]
[emms-player-mpd: Overhaul for streamlist support, and fix a few miscellaneous
issues.
Michael Olson <address@hidden>**20060524055707]
[emms-player-mpd: Add a few checks to make sure that the given buffer exists
before trying to do anything with it.
Michael Olson <address@hidden>**20060517035419]
[emms-source-playlist: Do not expand names of files in playlists, as this can
cause problems with emms-player-mpd in some configurations.
Michael Olson <address@hidden>**20060516081257]
[emms-playlist-mode: Implement the option (disabled by default) of opening a
new EMMS buffer for a playlist, when hitting RET on one.
Michael Olson <address@hidden>**20060510040730]
[emms-playlist-mode.el: Don't put a period after the mode map. This hangs 21.4
on display.
address@hidden
[TAG 2.0
address@hidden
Patch bundle hash:
41aa3ce7fe47e33d2d16db7bf82da696a029865b
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emms-patches] darcs patch: Very basic support for recording the time you last pla...,
lucas <=