2014-09-22 13:42:57 +00:00
|
|
|
;;; mpc.el --- A client for the Music Player Daemon -*- lexical-binding: t -*-
|
2009-12-01 04:04:33 +00:00
|
|
|
|
2023-01-01 10:31:12 +00:00
|
|
|
;; Copyright (C) 2006-2023 Free Software Foundation, Inc.
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
|
|
|
|
;; Keywords: multimedia
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs 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.
|
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; This is an Emacs front end to the Music Player Daemon.
|
|
|
|
|
|
|
|
;; It mostly provides a browser inspired from Rhythmbox for your music
|
|
|
|
;; collection and also allows you to play the music you select. The basic
|
|
|
|
;; interface is somewhat unusual in that it does not focus on the
|
|
|
|
;; playlist as much as on the browser.
|
|
|
|
;; I play albums rather than songs and thus don't have much need for
|
|
|
|
;; playlists, and it shows. Playlist support exists, but is still limited.
|
|
|
|
|
|
|
|
;; Bugs:
|
|
|
|
|
|
|
|
;; - when reaching end/start of song while ffwd/rewind, it may get wedged,
|
|
|
|
;; signal an error, ... or when mpc-next/prev is called while ffwd/rewind.
|
|
|
|
;; - MPD errors are not reported to the user.
|
|
|
|
|
|
|
|
;; Todo:
|
|
|
|
|
|
|
|
;; - add bindings/buttons/menuentries for the various commands.
|
|
|
|
;; - mpc-undo
|
|
|
|
;; - visual feedback for drag'n'drop
|
2009-12-02 02:08:21 +00:00
|
|
|
;; - display/set `repeat' and `random' state (and maybe also `crossfade').
|
2009-12-01 04:04:33 +00:00
|
|
|
;; - allow multiple *mpc* sessions in the same Emacs to control different mpds.
|
|
|
|
;; - fetch album covers and lyrics from the web?
|
|
|
|
;; - improve MPC-Status: better volume control, add a way to show/hide the
|
|
|
|
;; rest, plus add the buttons currently in the toolbar.
|
|
|
|
;; - improve mpc-songs-mode's header-line column-headings so they can be
|
|
|
|
;; dragged to resize.
|
|
|
|
;; - allow selecting several entries by drag-mouse.
|
|
|
|
;; - poll less often
|
|
|
|
;; - use the `idle' command
|
|
|
|
;; - do the time-ticking locally (and sync every once in a while)
|
|
|
|
;; - look at the end of play time to make sure we notice the end
|
|
|
|
;; as soon as possible
|
|
|
|
;; - better volume widget.
|
|
|
|
;; - add synthesized tags.
|
|
|
|
;; e.g. pseudo-artist = artist + composer + performer.
|
|
|
|
;; e.g. pseudo-performer = performer or artist
|
|
|
|
;; e.g. rewrite artist "Foo bar & baz" to "Foo bar".
|
|
|
|
;; e.g. filename regexp -> compilation flag
|
|
|
|
;; - window/buffer management.
|
|
|
|
;; - menubar, tooltips, ...
|
|
|
|
;; - add mpc-describe-song, mpc-describe-album, ...
|
|
|
|
;; - add import/export commands (especially export to an MP3 player).
|
|
|
|
;; - add a real notion of album (as opposed to just album-name):
|
|
|
|
;; if all songs with same album-name have same artist -> it's an album
|
|
|
|
;; else it's either several albums or a compilation album (or both),
|
|
|
|
;; in which case we could use heuristics or user provided info:
|
|
|
|
;; - if the user followed the 1-album = 1-dir idea, then we can group songs
|
|
|
|
;; by their directory to create albums.
|
|
|
|
;; - if a `compilation' flag is available, and if <=1 of the songs have it
|
|
|
|
;; set, then we can group songs by their artist to create albums.
|
|
|
|
;; - if two songs have the same track-nb and disk-nb, they're not in the
|
|
|
|
;; same album. So from the set of songs with identical album names, we
|
|
|
|
;; can get a lower bound on the number of albums involved, and then see
|
|
|
|
;; which of those may be non-compilations, etc...
|
|
|
|
;; - use a special directory name for compilations.
|
|
|
|
;; - ask the web ;-)
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
;; Prefixes used in this code:
|
|
|
|
;; mpc-proc : management of connection (in/out formatting, ...)
|
|
|
|
;; mpc-status : auto-updated status info
|
|
|
|
;; mpc-volume : stuff handling the volume widget
|
|
|
|
;; mpc-cmd : mpdlib abstraction
|
|
|
|
|
|
|
|
;; UI-commands : mpc-
|
|
|
|
;; internal : mpc--
|
|
|
|
|
2015-10-13 18:19:18 +00:00
|
|
|
(eval-when-compile
|
|
|
|
(require 'cl-lib)
|
|
|
|
(require 'subr-x))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defgroup mpc ()
|
2012-04-22 13:58:00 +00:00
|
|
|
"Client for the Music Player Daemon (mpd)."
|
2009-12-01 04:04:33 +00:00
|
|
|
:prefix "mpc-"
|
|
|
|
:group 'multimedia
|
|
|
|
:group 'applications)
|
|
|
|
|
2010-03-25 00:06:08 +00:00
|
|
|
(defcustom mpc-browser-tags '(Genre Artist|Composer|Performer
|
|
|
|
Album|Playlist)
|
2009-12-01 04:04:33 +00:00
|
|
|
"Tags for which a browser buffer should be created by default."
|
2010-03-25 00:06:08 +00:00
|
|
|
;; FIXME: provide a list of tags, for completion.
|
|
|
|
:type '(repeat symbol))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;;; Misc utils ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun mpc-assq-all (key alist)
|
|
|
|
(let ((res ()) val)
|
|
|
|
(dolist (elem alist)
|
|
|
|
(if (and (eq (car elem) key)
|
|
|
|
(not (member (setq val (cdr elem)) res)))
|
|
|
|
(push val res)))
|
|
|
|
(nreverse res)))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-union (&rest lists)
|
|
|
|
(let ((res (nreverse (pop lists))))
|
|
|
|
(dolist (list lists)
|
|
|
|
(let ((seen res)) ;Don't remove duplicates within each list.
|
|
|
|
(dolist (elem list)
|
|
|
|
(unless (member elem seen) (push elem res)))))
|
|
|
|
(nreverse res)))
|
|
|
|
|
2021-06-03 22:05:01 +00:00
|
|
|
(defun mpc-intersection (l1 l2 selectfun)
|
2009-12-01 04:04:33 +00:00
|
|
|
"Return L1 after removing all elements not found in L2.
|
2021-06-03 22:05:01 +00:00
|
|
|
Elements aren't compared directly, but instead
|
2009-12-02 02:08:21 +00:00
|
|
|
they are passed through SELECTFUN before comparison."
|
2021-06-03 22:05:01 +00:00
|
|
|
(seq-intersection l1 l2 (lambda (x y)
|
|
|
|
(equal (funcall selectfun x)
|
|
|
|
(funcall selectfun y)))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-event-set-point (event)
|
|
|
|
(condition-case nil (posn-set-point (event-end event))
|
|
|
|
(error (condition-case nil (mouse-set-point event)
|
|
|
|
(error nil)))))
|
|
|
|
|
|
|
|
(defun mpc-compare-strings (str1 str2 &optional ignore-case)
|
|
|
|
"Compare strings STR1 and STR2.
|
|
|
|
Contrary to `compare-strings', this tries to get numbers sorted
|
|
|
|
numerically rather than lexicographically."
|
|
|
|
(let ((res (compare-strings str1 nil nil str2 nil nil ignore-case)))
|
|
|
|
(if (not (integerp res)) res
|
|
|
|
(let ((index (1- (abs res))))
|
|
|
|
(if (or (>= index (length str1)) (>= index (length str2)))
|
|
|
|
res
|
|
|
|
(let ((digit1 (memq (aref str1 index)
|
|
|
|
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)))
|
|
|
|
(digit2 (memq (aref str2 index)
|
|
|
|
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))))
|
|
|
|
(if digit1
|
|
|
|
(if digit2
|
|
|
|
(let ((num1 (progn (string-match "[0-9]+" str1 index)
|
|
|
|
(match-string 0 str1)))
|
|
|
|
(num2 (progn (string-match "[0-9]+" str2 index)
|
|
|
|
(match-string 0 str2))))
|
|
|
|
(cond
|
|
|
|
;; Here we presume that leading zeroes are only used
|
|
|
|
;; for same-length numbers. So we'll incorrectly
|
|
|
|
;; consider that "000" comes after "01", but I don't
|
|
|
|
;; think it matters.
|
|
|
|
((< (length num1) (length num2)) (- (abs res)))
|
|
|
|
((> (length num1) (length num2)) (abs res))
|
|
|
|
((< (string-to-number num1) (string-to-number num2))
|
|
|
|
(- (abs res)))
|
|
|
|
(t (abs res))))
|
|
|
|
;; "1a" comes before "10", but "0" comes before "a".
|
|
|
|
(if (and (not (zerop index))
|
|
|
|
(memq (aref str1 (1- index))
|
|
|
|
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)))
|
|
|
|
(abs res)
|
|
|
|
(- (abs res))))
|
|
|
|
(if digit2
|
|
|
|
;; "1a" comes before "10", but "0" comes before "a".
|
|
|
|
(if (and (not (zerop index))
|
|
|
|
(memq (aref str1 (1- index))
|
|
|
|
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)))
|
|
|
|
(- (abs res))
|
|
|
|
(abs res))
|
|
|
|
res))))))))
|
|
|
|
|
|
|
|
;; This can speed up mpc--song-search significantly. The table may grow
|
|
|
|
;; very large, tho. It's only bounded by the fact that it gets flushed
|
|
|
|
;; whenever the connection is established; which seems to work OK thanks
|
|
|
|
;; to the fact that MPD tends to disconnect fairly often, although our
|
|
|
|
;; constant polling often prevents disconnection.
|
|
|
|
(defvar mpc--find-memoize (make-hash-table :test 'equal)) ;; :weakness t
|
2013-03-29 14:23:24 +00:00
|
|
|
(defvar-local mpc-tag nil)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;;; Support for the actual connection and MPD command execution ;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defcustom mpc-host
|
|
|
|
(concat (or (getenv "MPD_HOST") "localhost")
|
|
|
|
(if (getenv "MPD_PORT") (concat ":" (getenv "MPD_PORT"))))
|
2021-09-14 06:43:18 +00:00
|
|
|
"Host (and port) where the Music Player Daemon is running.
|
|
|
|
The format is \"HOST\", \"HOST:PORT\", \"PASSWORD@HOST\" or
|
|
|
|
\"PASSWORD@HOST:PORT\" where PASSWORD defaults to no password,
|
|
|
|
PORT defaults to 6600 and HOST defaults to localhost."
|
2009-12-01 04:04:33 +00:00
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defvar mpc-proc nil)
|
|
|
|
|
|
|
|
(defconst mpc--proc-end-re "^\\(?:OK\\(?: MPD .*\\)?\\|ACK \\(.*\\)\\)\n")
|
|
|
|
|
* lisp/subr.el (define-error): New function.
* doc/lispref/control.texi (Signaling Errors): Refer to define-error.
(Error Symbols): Add `define-error'.
* doc/lispref/errors.texi (Standard Errors): Don't refer to `error-conditions'.
* lisp/progmodes/ada-xref.el (ada-error-file-not-found): Rename from
error-file-not-found and define with define-error.
* lisp/emacs-lisp/cl-lib.el (cl-assertion-failed): Move here from subr.el
and define with define-error.
* lisp/userlock.el (file-locked, file-supersession):
* lisp/simple.el (mark-inactive):
* lisp/progmodes/js.el (js-moz-bad-rpc, js-js-error):
* lisp/progmodes/ada-mode.el (ada-mode-errors):
* lisp/play/life.el (life-extinct):
* lisp/nxml/xsd-regexp.el (xsdre-invalid-regexp, xsdre-parse-error):
* lisp/nxml/xmltok.el (xmltok-markup-declaration-parse-error):
* lisp/nxml/rng-util.el (rng-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-cmpct.el (rng-c-incorrect-schema):
* lisp/nxml/nxml-util.el (nxml-error, nxml-file-parse-error):
* lisp/nxml/nxml-rap.el (nxml-scan-error):
* lisp/nxml/nxml-outln.el (nxml-outline-error):
* lisp/net/soap-client.el (soap-error):
* lisp/net/gnutls.el (gnutls-error):
* lisp/net/ange-ftp.el (ftp-error):
* lisp/mpc.el (mpc-proc-error):
* lisp/json.el (json-error, json-readtable-error, json-unknown-keyword)
(json-number-format, json-string-escape, json-string-format)
(json-key-format, json-object-format):
* lisp/jka-compr.el (compression-error):
* lisp/international/quail.el (quail-error):
* lisp/international/kkc.el (kkc-error):
* lisp/emacs-lisp/ert.el (ert-test-failed):
* lisp/calc/calc.el (calc-error, inexact-result, math-overflow)
(math-underflow):
* lisp/bookmark.el (bookmark-error-no-filename):
* lisp/epg.el (epg-error): Define with define-error.
2013-08-09 21:22:44 +00:00
|
|
|
(define-error 'mpc-proc-error "MPD error")
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc--debug (format &rest args)
|
|
|
|
(if (get-buffer "*MPC-debug*")
|
|
|
|
(with-current-buffer "*MPC-debug*"
|
|
|
|
(goto-char (point-max))
|
|
|
|
(insert-before-markers ;So it scrolls.
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 16:58:46 +00:00
|
|
|
(string-replace "\n" "\n "
|
|
|
|
(apply #'format-message format args))
|
2009-12-01 04:04:33 +00:00
|
|
|
"\n"))))
|
|
|
|
|
|
|
|
(defun mpc--proc-filter (proc string)
|
|
|
|
(mpc--debug "Receive \"%s\"" string)
|
|
|
|
(with-current-buffer (process-buffer proc)
|
|
|
|
(if (process-get proc 'ready)
|
|
|
|
(if nil ;; (string-match "\\`\\(OK\n\\)+\\'" string)
|
|
|
|
;; I haven't figured out yet why I get those extraneous OKs,
|
|
|
|
;; so I'll just ignore them for now.
|
|
|
|
nil
|
|
|
|
(delete-process proc)
|
|
|
|
(set-process-buffer proc nil)
|
|
|
|
(pop-to-buffer (clone-buffer))
|
|
|
|
(error "MPD output while idle!?"))
|
|
|
|
(save-excursion
|
|
|
|
(let ((start (or (marker-position (process-mark proc)) (point-min))))
|
|
|
|
(goto-char start)
|
|
|
|
(insert string)
|
|
|
|
(move-marker (process-mark proc) (point))
|
|
|
|
(beginning-of-line)
|
|
|
|
(when (and (< start (point))
|
|
|
|
(re-search-backward mpc--proc-end-re start t))
|
|
|
|
(process-put proc 'ready t)
|
|
|
|
(unless (eq (match-end 0) (point-max))
|
|
|
|
(error "Unexpected trailing text"))
|
2011-08-24 01:55:10 +00:00
|
|
|
(let ((error-text (match-string 1)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(delete-region (point) (point-max))
|
|
|
|
(let ((callback (process-get proc 'callback)))
|
|
|
|
(process-put proc 'callback nil)
|
2011-08-24 01:55:10 +00:00
|
|
|
(if error-text
|
|
|
|
(process-put proc 'mpc-proc-error error-text))
|
2009-12-01 04:04:33 +00:00
|
|
|
(funcall callback)))))))))
|
|
|
|
|
|
|
|
(defun mpc--proc-connect (host)
|
2012-08-04 07:37:27 +00:00
|
|
|
(let ((port 6600)
|
2015-09-03 15:47:31 +00:00
|
|
|
local
|
2012-08-04 07:37:27 +00:00
|
|
|
pass)
|
|
|
|
|
|
|
|
(when (string-match "\\`\\(?:\\(.*\\)@\\)?\\(.*?\\)\\(?::\\(.*\\)\\)?\\'"
|
|
|
|
host)
|
|
|
|
(let ((v (match-string 1 host)))
|
|
|
|
(when (and (stringp v) (not (string= "" v)))
|
|
|
|
(setq pass v)))
|
|
|
|
(let ((v (match-string 3 host)))
|
|
|
|
(setq host (match-string 2 host))
|
|
|
|
(when (and (stringp v) (not (string= "" v)))
|
2016-03-08 02:54:25 +00:00
|
|
|
(setq port v))))
|
2015-09-07 22:01:00 +00:00
|
|
|
(when (file-name-absolute-p host)
|
|
|
|
;; Expand file name because `file-name-absolute-p'
|
|
|
|
;; considers paths beginning with "~" as absolute
|
|
|
|
(setq host (expand-file-name host))
|
2015-09-03 15:47:31 +00:00
|
|
|
(setq local t))
|
2012-08-04 07:37:27 +00:00
|
|
|
|
|
|
|
(mpc--debug "Connecting to %s:%s..." host port)
|
|
|
|
(with-current-buffer (get-buffer-create (format " *mpc-%s:%s*" host port))
|
|
|
|
;; (pop-to-buffer (current-buffer))
|
|
|
|
(let (proc)
|
|
|
|
(while (and (setq proc (get-buffer-process (current-buffer)))
|
|
|
|
(progn ;; (debug)
|
|
|
|
(delete-process proc)))))
|
|
|
|
(erase-buffer)
|
2009-12-01 04:04:33 +00:00
|
|
|
(let* ((coding-system-for-read 'utf-8-unix)
|
|
|
|
(coding-system-for-write 'utf-8-unix)
|
2013-03-29 14:23:24 +00:00
|
|
|
(proc (condition-case err
|
2015-09-03 15:47:31 +00:00
|
|
|
(make-network-process :name "MPC" :buffer (current-buffer)
|
|
|
|
:host (unless local host)
|
|
|
|
:service (if local host port)
|
|
|
|
:family (if local 'local))
|
2013-03-29 14:23:24 +00:00
|
|
|
(error (user-error (error-message-string err))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(when (processp mpc-proc)
|
|
|
|
;; Inherit the properties of the previous connection.
|
|
|
|
(let ((plist (process-plist mpc-proc)))
|
|
|
|
(while plist (process-put proc (pop plist) (pop plist)))))
|
|
|
|
(mpc-proc-buffer proc 'mpd-commands (current-buffer))
|
2021-04-24 19:57:22 +00:00
|
|
|
(process-put proc 'callback #'ignore)
|
2009-12-01 04:04:33 +00:00
|
|
|
(process-put proc 'ready nil)
|
|
|
|
(clrhash mpc--find-memoize)
|
2021-04-24 19:57:22 +00:00
|
|
|
(set-process-filter proc #'mpc--proc-filter)
|
|
|
|
(set-process-sentinel proc #'ignore)
|
2009-12-01 04:04:33 +00:00
|
|
|
(set-process-query-on-exit-flag proc nil)
|
|
|
|
;; This may be called within a process filter ;-(
|
|
|
|
(with-local-quit (mpc-proc-sync proc))
|
2012-08-04 07:37:27 +00:00
|
|
|
(setq mpc-proc proc)
|
|
|
|
(when pass
|
|
|
|
(mpc-proc-cmd (list "password" pass) nil))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc--proc-quote-string (s)
|
|
|
|
(if (numberp s) (number-to-string s)
|
|
|
|
(setq s (replace-regexp-in-string "[\"\\]" "\\\\\\&" s))
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
(if (string-search " " s) (concat "\"" s "\"") s)))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defconst mpc--proc-alist-to-alists-starters '(file directory))
|
|
|
|
|
|
|
|
(defun mpc--proc-alist-to-alists (alist)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-assert (or (null alist)
|
2009-12-01 04:04:33 +00:00
|
|
|
(memq (caar alist) mpc--proc-alist-to-alists-starters)))
|
|
|
|
(let ((starter (caar alist))
|
|
|
|
(alists ())
|
|
|
|
tmp)
|
|
|
|
(dolist (pair alist)
|
|
|
|
(when (eq (car pair) starter)
|
|
|
|
(if tmp (push (nreverse tmp) alists))
|
|
|
|
(setq tmp ()))
|
|
|
|
(push pair tmp))
|
|
|
|
(if tmp (push (nreverse tmp) alists))
|
|
|
|
(nreverse alists)))
|
|
|
|
|
2013-04-10 13:17:27 +00:00
|
|
|
(defun mpc-proc (&optional restart)
|
2012-08-04 07:37:27 +00:00
|
|
|
(unless (and mpc-proc
|
|
|
|
(buffer-live-p (process-buffer mpc-proc))
|
2013-04-10 13:17:27 +00:00
|
|
|
(not (and restart
|
|
|
|
(memq (process-status mpc-proc) '(closed)))))
|
2012-08-04 07:37:27 +00:00
|
|
|
(mpc--proc-connect mpc-host))
|
|
|
|
mpc-proc)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
2011-08-24 01:55:10 +00:00
|
|
|
(defun mpc-proc-check (proc)
|
|
|
|
(let ((error-text (process-get proc 'mpc-proc-error)))
|
|
|
|
(when error-text
|
|
|
|
(process-put proc 'mpc-proc-error nil)
|
|
|
|
(signal 'mpc-proc-error error-text))))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-proc-sync (&optional proc)
|
|
|
|
"Wait for MPC process until it is idle again.
|
|
|
|
Return the buffer in which the process is/was running."
|
|
|
|
(unless proc (setq proc (mpc-proc)))
|
|
|
|
(unwind-protect
|
2011-08-24 01:55:10 +00:00
|
|
|
(progn
|
|
|
|
(while (and (not (process-get proc 'ready))
|
|
|
|
(accept-process-output proc)))
|
|
|
|
(mpc-proc-check proc)
|
|
|
|
(if (process-get proc 'ready) (process-buffer proc)
|
|
|
|
(error "No response from MPD")))
|
2009-12-01 04:04:33 +00:00
|
|
|
(unless (process-get proc 'ready)
|
|
|
|
;; (debug)
|
|
|
|
(message "Killing hung process")
|
|
|
|
(delete-process proc))))
|
|
|
|
|
|
|
|
(defun mpc-proc-cmd (cmd &optional callback)
|
|
|
|
"Send command CMD to the MPD server.
|
|
|
|
If CALLBACK is nil, wait for the command to finish before returning,
|
|
|
|
otherwise return immediately and call CALLBACK with no argument
|
|
|
|
when the command terminates.
|
|
|
|
CMD can be a string which is passed as-is to MPD or a list of strings
|
|
|
|
which will be concatenated with proper quoting before passing them to MPD."
|
2013-04-10 13:17:27 +00:00
|
|
|
(let ((proc (mpc-proc 'restart)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (and callback (not (process-get proc 'ready)))
|
2011-02-10 18:53:49 +00:00
|
|
|
(let ((old (process-get proc 'callback)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(process-put proc 'callback
|
|
|
|
(lambda ()
|
|
|
|
(funcall old)
|
|
|
|
(mpc-proc-cmd cmd callback))))
|
|
|
|
;; Wait for any pending async command to terminate.
|
|
|
|
(mpc-proc-sync proc)
|
|
|
|
(process-put proc 'ready nil)
|
|
|
|
(with-current-buffer (process-buffer proc)
|
|
|
|
(erase-buffer)
|
|
|
|
(mpc--debug "Send \"%s\"" cmd)
|
|
|
|
(process-send-string
|
|
|
|
proc (concat (if (stringp cmd) cmd
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapconcat #'mpc--proc-quote-string cmd " "))
|
2009-12-01 04:04:33 +00:00
|
|
|
"\n")))
|
|
|
|
(if callback
|
2011-03-01 05:03:24 +00:00
|
|
|
;; (let ((buf (current-buffer)))
|
2011-08-24 01:55:10 +00:00
|
|
|
(process-put proc 'callback
|
|
|
|
callback
|
|
|
|
;; (lambda ()
|
|
|
|
;; (funcall callback
|
|
|
|
;; (prog1 (current-buffer)
|
|
|
|
;; (set-buffer buf)))))
|
|
|
|
)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; If `callback' is nil, we're executing synchronously.
|
2021-04-24 19:57:22 +00:00
|
|
|
(process-put proc 'callback #'ignore)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; This returns the process's buffer.
|
|
|
|
(mpc-proc-sync proc)))))
|
|
|
|
|
|
|
|
;; This function doesn't exist in Emacs-21.
|
|
|
|
;; (put 'mpc-proc-cmd-list 'byte-optimizer 'byte-optimize-pure-func)
|
|
|
|
(defun mpc-proc-cmd-list (cmds)
|
|
|
|
(concat "command_list_begin\n"
|
|
|
|
(mapconcat (lambda (cmd)
|
|
|
|
(if (stringp cmd) cmd
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapconcat #'mpc--proc-quote-string cmd " ")))
|
2009-12-01 04:04:33 +00:00
|
|
|
cmds
|
|
|
|
"\n")
|
|
|
|
"\ncommand_list_end"))
|
|
|
|
|
|
|
|
(defun mpc-proc-cmd-list-ok ()
|
|
|
|
;; To implement this, we'll need to tweak the process filter since we'd
|
|
|
|
;; then sometimes get "trailing" text after "OK\n".
|
|
|
|
(error "Not implemented yet"))
|
|
|
|
|
|
|
|
(defun mpc-proc-buf-to-alist (&optional buf)
|
|
|
|
(with-current-buffer (or buf (current-buffer))
|
|
|
|
(let ((res ()))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^\\([^:]+\\): \\(.*\\)\n" nil t)
|
|
|
|
(push (cons (intern (match-string 1)) (match-string 2)) res))
|
|
|
|
(nreverse res))))
|
|
|
|
|
|
|
|
(defun mpc-proc-buf-to-alists (buf)
|
|
|
|
(mpc--proc-alist-to-alists (mpc-proc-buf-to-alist buf)))
|
|
|
|
|
|
|
|
(defun mpc-proc-cmd-to-alist (cmd &optional callback)
|
|
|
|
(if callback
|
2011-02-10 18:53:49 +00:00
|
|
|
(let ((buf (current-buffer)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd cmd (lambda ()
|
|
|
|
(funcall callback (prog1 (mpc-proc-buf-to-alist
|
|
|
|
(current-buffer))
|
|
|
|
(set-buffer buf))))))
|
2012-04-26 12:43:28 +00:00
|
|
|
;; (let ((res nil))
|
2009-12-01 04:04:33 +00:00
|
|
|
;; (mpc-proc-cmd-to-alist cmd (lambda (alist) (setq res alist)))
|
|
|
|
;; (mpc-proc-sync)
|
|
|
|
;; res)
|
|
|
|
(mpc-proc-buf-to-alist (mpc-proc-cmd cmd))))
|
|
|
|
|
|
|
|
(defun mpc-proc-tag-string-to-sym (tag)
|
|
|
|
(intern (capitalize tag)))
|
|
|
|
|
|
|
|
(defun mpc-proc-buffer (proc use &optional buffer)
|
|
|
|
(let* ((bufs (process-get proc 'buffers))
|
|
|
|
(buf (cdr (assoc use bufs))))
|
|
|
|
(cond
|
|
|
|
((and buffer (buffer-live-p buf) (not (eq buffer buf)))
|
|
|
|
(error "Duplicate MPC buffer for %s" use))
|
|
|
|
(buffer
|
|
|
|
(if buf
|
|
|
|
(setcdr (assoc use bufs) buffer)
|
|
|
|
(process-put proc 'buffers (cons (cons use buffer) bufs))))
|
|
|
|
(t buf))))
|
|
|
|
|
|
|
|
;;; Support for regularly updated current status information ;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;; Exported elements:
|
2022-11-18 14:48:22 +00:00
|
|
|
;; `mpc-status' holds the up-to-date data.
|
2009-12-01 04:04:33 +00:00
|
|
|
;; `mpc-status-callbacks' holds the registered callback functions.
|
|
|
|
;; `mpc-status-refresh' forces a refresh of the data.
|
|
|
|
;; `mpc-status-stop' stops the automatic updating.
|
|
|
|
|
|
|
|
(defvar mpc-status nil)
|
|
|
|
(defvar mpc-status-callbacks
|
|
|
|
'((state . mpc--status-timers-refresh)
|
|
|
|
;; (song . mpc--queue-refresh)
|
|
|
|
;; (state . mpc--queue-refresh) ;To detect the end of the last song.
|
|
|
|
(state . mpc--faster-toggle-refresh) ;Only ffwd/rewind while play/pause.
|
|
|
|
(volume . mpc-volume-refresh)
|
|
|
|
(file . mpc-songpointer-refresh)
|
|
|
|
;; The song pointer may need updating even if the file doesn't change,
|
|
|
|
;; if the same song appears multiple times in a row.
|
|
|
|
(song . mpc-songpointer-refresh)
|
|
|
|
(updating_db . mpc-updated-db)
|
|
|
|
(updating_db . mpc--status-timers-refresh)
|
|
|
|
(t . mpc-current-refresh))
|
|
|
|
"Alist associating properties to the functions that care about them.
|
|
|
|
Each entry has the form (PROP . FUN) where PROP can be t to mean
|
|
|
|
to call FUN for any change whatsoever.")
|
|
|
|
|
|
|
|
(defun mpc--status-callback ()
|
|
|
|
(let ((old-status mpc-status))
|
|
|
|
;; Update the alist.
|
|
|
|
(setq mpc-status (mpc-proc-buf-to-alist))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-assert mpc-status)
|
2009-12-01 04:04:33 +00:00
|
|
|
(unless (equal old-status mpc-status)
|
|
|
|
;; Run the relevant refresher functions.
|
|
|
|
(dolist (pair mpc-status-callbacks)
|
|
|
|
(when (or (eq t (car pair))
|
|
|
|
(not (equal (cdr (assq (car pair) old-status))
|
|
|
|
(cdr (assq (car pair) mpc-status)))))
|
|
|
|
(funcall (cdr pair)))))))
|
|
|
|
|
|
|
|
(defvar mpc--status-timer nil)
|
|
|
|
(defun mpc--status-timer-start ()
|
2021-04-24 19:57:22 +00:00
|
|
|
(add-hook 'pre-command-hook #'mpc--status-timer-stop)
|
2009-12-01 04:04:33 +00:00
|
|
|
(unless mpc--status-timer
|
2021-04-24 19:57:22 +00:00
|
|
|
(setq mpc--status-timer (run-with-timer 1 1 #'mpc--status-timer-run))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc--status-timer-stop ()
|
|
|
|
(when mpc--status-timer
|
|
|
|
(cancel-timer mpc--status-timer)
|
|
|
|
(setq mpc--status-timer nil)))
|
|
|
|
(defun mpc--status-timer-run ()
|
2014-04-06 13:08:00 +00:00
|
|
|
(with-demoted-errors "MPC: %S"
|
2013-09-12 05:32:57 +00:00
|
|
|
(when (process-get (mpc-proc) 'ready)
|
2014-04-06 13:08:00 +00:00
|
|
|
(let* ((buf (mpc-proc-buffer (mpc-proc) 'status))
|
|
|
|
(win (get-buffer-window buf t)))
|
|
|
|
(if (not win)
|
|
|
|
(mpc--status-timer-stop)
|
|
|
|
(with-local-quit (mpc-status-refresh)))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defvar mpc--status-idle-timer nil)
|
|
|
|
(defun mpc--status-idle-timer-start ()
|
|
|
|
(when mpc--status-idle-timer
|
|
|
|
;; Turn it off even if we'll start it again, in case it changes the delay.
|
|
|
|
(cancel-timer mpc--status-idle-timer))
|
|
|
|
(setq mpc--status-idle-timer
|
2021-04-24 19:57:22 +00:00
|
|
|
(run-with-idle-timer 1 t #'mpc--status-idle-timer-run))
|
2009-12-01 04:04:33 +00:00
|
|
|
;; Typically, the idle timer is started from the mpc--status-callback,
|
|
|
|
;; which is run asynchronously while we're already idle (we typically
|
|
|
|
;; just started idling), so the timer itself will only be run the next
|
|
|
|
;; time we idle :-(
|
|
|
|
;; To work around that, we immediately start the repeat timer.
|
|
|
|
(mpc--status-timer-start))
|
|
|
|
(defun mpc--status-idle-timer-stop (&optional really)
|
|
|
|
(when mpc--status-idle-timer
|
|
|
|
;; Turn it off even if we'll start it again, in case it changes the delay.
|
|
|
|
(cancel-timer mpc--status-idle-timer))
|
|
|
|
(setq mpc--status-idle-timer
|
|
|
|
(unless really
|
|
|
|
;; We don't completely stop the timer, so that if some other MPD
|
|
|
|
;; client starts playback, we may get a chance to notice it.
|
2021-04-24 19:57:22 +00:00
|
|
|
(run-with-idle-timer 10 t #'mpc--status-idle-timer-run))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc--status-idle-timer-run ()
|
2014-04-06 13:08:00 +00:00
|
|
|
(mpc--status-timer-start)
|
|
|
|
(mpc--status-timer-run))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc--status-timers-refresh ()
|
|
|
|
"Start/stop the timers according to whether a song is playing."
|
|
|
|
(if (or (member (cdr (assq 'state mpc-status)) '("play"))
|
|
|
|
(cdr (assq 'updating_db mpc-status)))
|
|
|
|
(mpc--status-idle-timer-start)
|
|
|
|
(mpc--status-idle-timer-stop)
|
|
|
|
(mpc--status-timer-stop)))
|
|
|
|
|
|
|
|
(defun mpc-status-refresh (&optional callback)
|
|
|
|
"Refresh `mpc-status'."
|
2011-02-10 18:53:49 +00:00
|
|
|
(let ((cb callback))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd (mpc-proc-cmd-list '("status" "currentsong"))
|
|
|
|
(lambda ()
|
|
|
|
(mpc--status-callback)
|
|
|
|
(if cb (funcall cb))))))
|
|
|
|
|
|
|
|
(defun mpc-status-stop ()
|
|
|
|
"Stop the autorefresh of `mpc-status'.
|
|
|
|
This is normally used only when quitting MPC.
|
|
|
|
Any call to `mpc-status-refresh' may cause it to be restarted."
|
|
|
|
(setq mpc-status nil)
|
|
|
|
(mpc--status-idle-timer-stop 'really)
|
|
|
|
(mpc--status-timer-stop))
|
|
|
|
|
|
|
|
;;; A thin layer above the raw protocol commands ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
;; (defvar mpc-queue nil)
|
|
|
|
;; (defvar mpc-queue-back nil)
|
|
|
|
|
|
|
|
;; (defun mpc--queue-head ()
|
|
|
|
;; (if (stringp (car mpc-queue)) (car mpc-queue) (cadar mpc-queue)))
|
|
|
|
;; (defun mpc--queue-pop ()
|
|
|
|
;; (when mpc-queue ;Can be nil if out of sync.
|
|
|
|
;; (let ((song (car mpc-queue)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
;; (cl-assert song)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; (push (if (and (consp song) (cddr song))
|
|
|
|
;; ;; The queue's first element is itself a list of
|
|
|
|
;; ;; songs, where the first element isn't itself a song
|
|
|
|
;; ;; but a description of the list.
|
|
|
|
;; (prog1 (cadr song) (setcdr song (cddr song)))
|
|
|
|
;; (prog1 (if (consp song) (cadr song) song)
|
|
|
|
;; (setq mpc-queue (cdr mpc-queue))))
|
|
|
|
;; mpc-queue-back)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
;; (cl-assert (stringp (car mpc-queue-back))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;; (defun mpc--queue-refresh ()
|
|
|
|
;; ;; Maintain the queue.
|
|
|
|
;; (mpc--debug "mpc--queue-refresh")
|
|
|
|
;; (let ((pos (cdr (or (assq 'Pos mpc-status) (assq 'song mpc-status)))))
|
|
|
|
;; (cond
|
|
|
|
;; ((null pos)
|
|
|
|
;; (mpc-cmd-clear 'ignore))
|
|
|
|
;; ((or (not (member pos '("0" nil)))
|
|
|
|
;; ;; There's only one song in the playlist and we've stopped.
|
|
|
|
;; ;; Maybe it's because of some external client that set the
|
|
|
|
;; ;; playlist like that and/or manually stopped the playback, but
|
|
|
|
;; ;; it's more likely that we've simply reached the end of
|
|
|
|
;; ;; the song. So remove it.
|
|
|
|
;; (and (equal (assq 'state mpc-status) "stop")
|
|
|
|
;; (equal (assq 'playlistlength mpc-status) "1")
|
|
|
|
;; (setq pos "1")))
|
|
|
|
;; ;; We're not playing the first song in the queue/playlist any
|
|
|
|
;; ;; more, so update the queue.
|
|
|
|
;; (dotimes (i (string-to-number pos)) (mpc--queue-pop))
|
|
|
|
;; (mpc-proc-cmd (mpc-proc-cmd-list
|
|
|
|
;; (make-list (string-to-number pos) "delete 0"))
|
2021-04-24 19:57:22 +00:00
|
|
|
;; #'ignore)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; (if (not (equal (cdr (assq 'file mpc-status))
|
|
|
|
;; (mpc--queue-head)))
|
|
|
|
;; (message "MPC's queue is out of sync"))))))
|
|
|
|
|
2010-03-25 00:06:08 +00:00
|
|
|
(defvar mpc--find-memoize-union-tags nil)
|
|
|
|
|
|
|
|
(defun mpc-cmd-flush (tag value)
|
|
|
|
(puthash (cons tag value) nil mpc--find-memoize)
|
|
|
|
(dolist (uniontag mpc--find-memoize-union-tags)
|
|
|
|
(if (member (symbol-name tag) (split-string (symbol-name uniontag) "|"))
|
|
|
|
(puthash (cons uniontag value) nil mpc--find-memoize))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun mpc-cmd-special-tag-p (tag)
|
|
|
|
(or (memq tag '(Playlist Search Directory))
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
(string-search "|" (symbol-name tag))))
|
2010-03-25 00:06:08 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-cmd-find (tag value)
|
|
|
|
"Return a list of all songs whose tag TAG has value VALUE.
|
|
|
|
The songs are returned as alists."
|
|
|
|
(or (gethash (cons tag value) mpc--find-memoize)
|
|
|
|
(puthash (cons tag value)
|
|
|
|
(cond
|
|
|
|
((eq tag 'Playlist)
|
|
|
|
;; Special case for pseudo-tag playlist.
|
2011-03-01 05:03:24 +00:00
|
|
|
(let ((l (condition-case nil
|
2010-03-25 00:06:08 +00:00
|
|
|
(mpc-proc-buf-to-alists
|
|
|
|
(mpc-proc-cmd (list "listplaylistinfo" value)))
|
|
|
|
(mpc-proc-error
|
|
|
|
;; "[50@0] {listplaylistinfo} No such playlist"
|
|
|
|
nil)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(i 0))
|
|
|
|
(mapcar (lambda (s)
|
|
|
|
(prog1 (cons (cons 'Pos (number-to-string i)) s)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf i)))
|
2009-12-01 04:04:33 +00:00
|
|
|
l)))
|
|
|
|
((eq tag 'Search)
|
|
|
|
(mpc-proc-buf-to-alists
|
|
|
|
(mpc-proc-cmd (list "search" "any" value))))
|
|
|
|
((eq tag 'Directory)
|
|
|
|
(let ((pairs
|
|
|
|
(mpc-proc-buf-to-alist
|
|
|
|
(mpc-proc-cmd (list "listallinfo" value)))))
|
|
|
|
(mpc--proc-alist-to-alists
|
|
|
|
;; Strip away the `directory' entries.
|
|
|
|
(delq nil (mapcar (lambda (pair)
|
|
|
|
(if (eq (car pair) 'directory)
|
|
|
|
nil pair))
|
|
|
|
pairs)))))
|
2010-03-25 00:06:08 +00:00
|
|
|
((string-match "|" (symbol-name tag))
|
|
|
|
(add-to-list 'mpc--find-memoize-union-tags tag)
|
|
|
|
(let ((tag1 (intern (substring (symbol-name tag)
|
|
|
|
0 (match-beginning 0))))
|
|
|
|
(tag2 (intern (substring (symbol-name tag)
|
|
|
|
(match-end 0)))))
|
|
|
|
(mpc-union (mpc-cmd-find tag1 value)
|
|
|
|
(mpc-cmd-find tag2 value))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(t
|
2011-03-01 05:03:24 +00:00
|
|
|
(condition-case nil
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-buf-to-alists
|
|
|
|
(mpc-proc-cmd (list "find" (symbol-name tag) value)))
|
|
|
|
(mpc-proc-error
|
|
|
|
;; If `tag' is not one of the expected tags, MPD burps
|
|
|
|
;; about not having the relevant table. FIXME: check
|
|
|
|
;; the kind of error.
|
|
|
|
(error "Unknown tag %s" tag)
|
|
|
|
(let ((res ()))
|
|
|
|
(setq value (cons tag value))
|
|
|
|
(dolist (song (mpc-proc-buf-to-alists
|
|
|
|
(mpc-proc-cmd "listallinfo")))
|
|
|
|
(if (member value song) (push song res)))
|
|
|
|
res)))))
|
|
|
|
mpc--find-memoize)))
|
|
|
|
|
|
|
|
(defun mpc-cmd-list (tag &optional other-tag value)
|
|
|
|
;; FIXME: we could also provide a `mpc-cmd-list' alternative which
|
|
|
|
;; doesn't take an "other-tag value" constraint but a "song-list" instead.
|
|
|
|
;; That might be more efficient in some cases.
|
|
|
|
(cond
|
|
|
|
((eq tag 'Playlist)
|
|
|
|
(let ((pls (mpc-assq-all 'playlist (mpc-proc-cmd-to-alist "lsinfo"))))
|
|
|
|
(when other-tag
|
|
|
|
(dolist (pl (prog1 pls (setq pls nil)))
|
|
|
|
(let ((plsongs (mpc-cmd-find 'Playlist pl)))
|
2010-03-25 00:06:08 +00:00
|
|
|
(if (not (mpc-cmd-special-tag-p other-tag))
|
2009-12-01 04:04:33 +00:00
|
|
|
(when (member (cons other-tag value)
|
2021-04-24 19:57:22 +00:00
|
|
|
(apply #'append plsongs))
|
2009-12-01 04:04:33 +00:00
|
|
|
(push pl pls))
|
|
|
|
;; Problem N°2: we compute the intersection whereas all
|
|
|
|
;; we care about is whether it's empty. So we could
|
|
|
|
;; speed this up significantly.
|
|
|
|
;; We only compare file names, because the full song-entries
|
|
|
|
;; are slightly different (the ones in plsongs include
|
|
|
|
;; position and id info specific to the playlist), and it's
|
|
|
|
;; good enough because this is only used with "search", which
|
|
|
|
;; doesn't pay attention to playlists and URLs anyway.
|
|
|
|
(let* ((osongs (mpc-cmd-find other-tag value))
|
2021-04-24 19:57:22 +00:00
|
|
|
(ofiles (mpc-assq-all 'file (apply #'append osongs)))
|
|
|
|
(plfiles (mpc-assq-all 'file (apply #'append plsongs))))
|
2021-04-04 23:13:54 +00:00
|
|
|
(when (seq-intersection plfiles ofiles)
|
2009-12-01 04:04:33 +00:00
|
|
|
(push pl pls)))))))
|
|
|
|
pls))
|
|
|
|
|
|
|
|
((eq tag 'Directory)
|
|
|
|
(if (null other-tag)
|
2021-04-24 19:57:22 +00:00
|
|
|
(apply #'nconc
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-assq-all 'directory
|
|
|
|
(mpc-proc-buf-to-alist
|
|
|
|
(mpc-proc-cmd "lsinfo")))
|
|
|
|
(mapcar (lambda (dir)
|
|
|
|
(let ((shortdir
|
|
|
|
(if (get-text-property 0 'display dir)
|
|
|
|
(concat " "
|
|
|
|
(get-text-property 0 'display dir))
|
|
|
|
" ↪ "))
|
|
|
|
(subdirs
|
|
|
|
(mpc-assq-all 'directory
|
|
|
|
(mpc-proc-buf-to-alist
|
|
|
|
(mpc-proc-cmd (list "lsinfo" dir))))))
|
|
|
|
(dolist (subdir subdirs)
|
|
|
|
(put-text-property 0 (1+ (length dir))
|
|
|
|
'display shortdir
|
|
|
|
subdir))
|
|
|
|
subdirs))
|
|
|
|
(process-get (mpc-proc) 'Directory)))
|
|
|
|
;; If there's an other-tag, then just extract the dir info from the
|
|
|
|
;; list of other-tag's songs.
|
|
|
|
(let* ((other-songs (mpc-cmd-find other-tag value))
|
2021-04-24 19:57:22 +00:00
|
|
|
(files (mpc-assq-all 'file (apply #'append other-songs)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(dirs '()))
|
|
|
|
(dolist (file files)
|
|
|
|
(let ((dir (file-name-directory file)))
|
|
|
|
(if (and dir (setq dir (directory-file-name dir))
|
|
|
|
(not (equal dir (car dirs))))
|
|
|
|
(push dir dirs))))
|
|
|
|
;; Dirs might have duplicates still.
|
|
|
|
(setq dirs (delete-dups dirs))
|
|
|
|
(let ((newdirs dirs))
|
|
|
|
(while newdirs
|
|
|
|
(let ((dir (file-name-directory (pop newdirs))))
|
|
|
|
(when (and dir (setq dir (directory-file-name dir))
|
|
|
|
(not (member dir dirs)))
|
|
|
|
(push dir newdirs)
|
|
|
|
(push dir dirs)))))
|
|
|
|
dirs)))
|
|
|
|
|
|
|
|
;; The UI should not provide access to such a thing anyway currently.
|
|
|
|
;; But I could imagine adding in the future a browser for the "search"
|
|
|
|
;; tag, which would provide things like previous searches. Not sure how
|
|
|
|
;; useful that would be tho.
|
|
|
|
((eq tag 'Search) (error "Not supported"))
|
|
|
|
|
2010-03-25 00:06:08 +00:00
|
|
|
((string-match "|" (symbol-name tag))
|
|
|
|
(let ((tag1 (intern (substring (symbol-name tag)
|
|
|
|
0 (match-beginning 0))))
|
|
|
|
(tag2 (intern (substring (symbol-name tag)
|
|
|
|
(match-end 0)))))
|
|
|
|
(mpc-union (mpc-cmd-list tag1 other-tag value)
|
|
|
|
(mpc-cmd-list tag2 other-tag value))))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
((null other-tag)
|
|
|
|
(condition-case nil
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapcar #'cdr (mpc-proc-cmd-to-alist (list "list" (symbol-name tag))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-error
|
|
|
|
;; If `tag' is not one of the expected tags, MPD burps about not
|
|
|
|
;; having the relevant table.
|
|
|
|
;; FIXME: check the kind of error.
|
|
|
|
(error "MPD does not know this tag %s" tag)
|
|
|
|
(mpc-assq-all tag (mpc-proc-cmd-to-alist "listallinfo")))))
|
|
|
|
(t
|
|
|
|
(condition-case nil
|
2010-03-25 00:06:08 +00:00
|
|
|
(if (mpc-cmd-special-tag-p other-tag)
|
2009-12-01 04:04:33 +00:00
|
|
|
(signal 'mpc-proc-error "Not implemented")
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapcar #'cdr
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd-to-alist
|
|
|
|
(list "list" (symbol-name tag)
|
|
|
|
(symbol-name other-tag) value))))
|
|
|
|
(mpc-proc-error
|
|
|
|
;; DAMN!! the 3-arg form of `list' is new in 0.12 !!
|
|
|
|
;; FIXME: check the kind of error.
|
|
|
|
(let ((other-songs (mpc-cmd-find other-tag value)))
|
|
|
|
(mpc-assq-all tag
|
|
|
|
;; Don't use `nconc' now that mpc-cmd-find may
|
|
|
|
;; return a memoized result.
|
2021-04-24 19:57:22 +00:00
|
|
|
(apply #'append other-songs))))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-cmd-stop (&optional callback)
|
|
|
|
(mpc-proc-cmd "stop" callback))
|
|
|
|
|
|
|
|
(defun mpc-cmd-clear (&optional callback)
|
|
|
|
(mpc-proc-cmd "clear" callback)
|
|
|
|
;; (setq mpc-queue-back nil mpc-queue nil)
|
|
|
|
)
|
|
|
|
|
2015-10-15 16:32:59 +00:00
|
|
|
(defun mpc-cmd-consume (&optional arg)
|
|
|
|
"Set consume mode state."
|
|
|
|
(mpc-proc-cmd (list "consume" arg) #'mpc-status-refresh))
|
|
|
|
|
|
|
|
(defun mpc-cmd-random (&optional arg)
|
|
|
|
"Set random (shuffle) mode state."
|
|
|
|
(mpc-proc-cmd (list "random" arg) #'mpc-status-refresh))
|
|
|
|
|
|
|
|
(defun mpc-cmd-repeat (&optional arg)
|
|
|
|
"Set repeat mode state."
|
|
|
|
(mpc-proc-cmd (list "repeat" arg) #'mpc-status-refresh))
|
|
|
|
|
|
|
|
(defun mpc-cmd-single (&optional arg)
|
|
|
|
"Set single mode state."
|
|
|
|
(mpc-proc-cmd (list "single" arg) #'mpc-status-refresh))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-cmd-pause (&optional arg callback)
|
|
|
|
"Pause or resume playback of the queue of songs."
|
2011-02-10 18:53:49 +00:00
|
|
|
(let ((cb callback))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd (list "pause" arg)
|
|
|
|
(lambda () (mpc-status-refresh) (if cb (funcall cb))))
|
|
|
|
(unless callback (mpc-proc-sync))))
|
|
|
|
|
|
|
|
(defun mpc-cmd-status ()
|
|
|
|
(mpc-proc-cmd-to-alist "status"))
|
|
|
|
|
2020-10-20 11:20:48 +00:00
|
|
|
(defun mpc-cmd-play (&optional sn)
|
|
|
|
(mpc-proc-cmd (if sn (list "play" sn) "play"))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-status-refresh))
|
|
|
|
|
2015-11-18 18:46:24 +00:00
|
|
|
(defun mpc-cmd-seekcur (time)
|
|
|
|
(mpc-proc-cmd (list "seekcur" time) #'mpc-status-refresh))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-cmd-add (files &optional playlist)
|
|
|
|
"Add the songs FILES to PLAYLIST.
|
|
|
|
If PLAYLIST is t or nil or missing, use the main playlist."
|
|
|
|
(mpc-proc-cmd (mpc-proc-cmd-list
|
|
|
|
(mapcar (lambda (file)
|
|
|
|
(if (stringp playlist)
|
|
|
|
(list "playlistadd" playlist file)
|
|
|
|
(list "add" file)))
|
|
|
|
files)))
|
|
|
|
(if (stringp playlist)
|
2010-03-25 00:06:08 +00:00
|
|
|
(mpc-cmd-flush 'Playlist playlist)))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-cmd-delete (song-poss &optional playlist)
|
|
|
|
"Delete the songs at positions SONG-POSS from PLAYLIST.
|
|
|
|
If PLAYLIST is t or nil or missing, use the main playlist."
|
|
|
|
(mpc-proc-cmd (mpc-proc-cmd-list
|
|
|
|
(mapcar (lambda (song-pos)
|
|
|
|
(if (stringp playlist)
|
|
|
|
(list "playlistdelete" playlist song-pos)
|
|
|
|
(list "delete" song-pos)))
|
|
|
|
;; Sort them from last to first, so the renumbering
|
|
|
|
;; caused by the earlier deletions don't affect
|
|
|
|
;; later ones.
|
2021-04-24 19:57:22 +00:00
|
|
|
(sort (copy-sequence song-poss) #'>))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (stringp playlist)
|
|
|
|
(puthash (cons 'Playlist playlist) nil mpc--find-memoize)))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-cmd-move (song-poss dest-pos &optional playlist)
|
|
|
|
(let ((i 0))
|
|
|
|
(mpc-proc-cmd
|
|
|
|
(mpc-proc-cmd-list
|
|
|
|
(mapcar (lambda (song-pos)
|
|
|
|
(if (>= song-pos dest-pos)
|
|
|
|
;; positions past dest-pos have been
|
|
|
|
;; shifted by i.
|
|
|
|
(setq song-pos (+ song-pos i)))
|
|
|
|
(prog1 (if (stringp playlist)
|
|
|
|
(list "playlistmove" playlist song-pos dest-pos)
|
|
|
|
(list "move" song-pos dest-pos))
|
|
|
|
(if (< song-pos dest-pos)
|
|
|
|
;; This move has shifted dest-pos by 1.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-decf dest-pos))
|
|
|
|
(cl-incf i)))
|
2009-12-01 04:04:33 +00:00
|
|
|
;; Sort them from last to first, so the renumbering
|
|
|
|
;; caused by the earlier deletions affect
|
|
|
|
;; later ones a bit less.
|
2021-04-24 19:57:22 +00:00
|
|
|
(sort (copy-sequence song-poss) #'>))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (stringp playlist)
|
|
|
|
(puthash (cons 'Playlist playlist) nil mpc--find-memoize))))
|
|
|
|
|
|
|
|
(defun mpc-cmd-update (&optional arg callback)
|
2011-02-10 18:53:49 +00:00
|
|
|
(let ((cb callback))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd (if arg (list "update" arg) "update")
|
|
|
|
(lambda () (mpc-status-refresh) (if cb (funcall cb))))
|
|
|
|
(unless callback (mpc-proc-sync))))
|
|
|
|
|
|
|
|
(defun mpc-cmd-tagtypes ()
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapcar #'cdr (mpc-proc-cmd-to-alist "tagtypes")))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;; This was never integrated into MPD.
|
|
|
|
;; (defun mpc-cmd-download (file)
|
|
|
|
;; (with-current-buffer (generate-new-buffer " *mpc download*")
|
|
|
|
;; (set-buffer-multibyte nil)
|
|
|
|
;; (let* ((proc (mpc-proc))
|
|
|
|
;; (stdbuf (process-buffer proc))
|
|
|
|
;; (markpos (marker-position (process-mark proc)))
|
|
|
|
;; (stdcoding (process-coding-system proc)))
|
|
|
|
;; (unwind-protect
|
|
|
|
;; (progn
|
|
|
|
;; (set-process-buffer proc (current-buffer))
|
|
|
|
;; (set-process-coding-system proc 'binary (cdr stdcoding))
|
|
|
|
;; (set-marker (process-mark proc) (point))
|
|
|
|
;; (mpc-proc-cmd (list "download" file)))
|
|
|
|
;; (set-process-buffer proc stdbuf)
|
|
|
|
;; (set-marker (process-mark proc) markpos stdbuf)
|
|
|
|
;; (set-process-coding-system proc (car stdcoding) (cdr stdcoding)))
|
|
|
|
;; ;; The command has completed, let's decode.
|
|
|
|
;; (goto-char (point-max))
|
|
|
|
;; (delete-char -1) ;Delete final newline.
|
|
|
|
;; (while (re-search-backward "^>" nil t)
|
|
|
|
;; (delete-char 1))
|
|
|
|
;; (current-buffer))))
|
|
|
|
|
|
|
|
;;; Misc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defcustom mpc-mpd-music-directory nil
|
|
|
|
"Location of MPD's music directory."
|
|
|
|
:type '(choice (const nil) directory))
|
|
|
|
|
|
|
|
(defcustom mpc-data-directory
|
2014-09-22 13:42:57 +00:00
|
|
|
(locate-user-emacs-file "mpc" ".mpc")
|
2009-12-01 04:04:33 +00:00
|
|
|
"Directory where MPC.el stores auxiliary data."
|
|
|
|
:type 'directory)
|
|
|
|
|
|
|
|
(defun mpc-data-directory ()
|
|
|
|
(unless (file-directory-p mpc-data-directory)
|
|
|
|
(make-directory mpc-data-directory))
|
|
|
|
mpc-data-directory)
|
|
|
|
|
|
|
|
(defun mpc-file-local-copy (file)
|
|
|
|
;; Try to set mpc-mpd-music-directory.
|
|
|
|
(when (and (null mpc-mpd-music-directory)
|
2015-09-07 21:57:46 +00:00
|
|
|
(or (string-match "\\`localhost" mpc-host)
|
|
|
|
(file-name-absolute-p mpc-host)))
|
2015-09-07 21:56:06 +00:00
|
|
|
(let ((files `(,(let ((xdg (getenv "XDG_CONFIG_HOME")))
|
|
|
|
(concat (if (and xdg (file-name-absolute-p xdg))
|
|
|
|
xdg "~/.config")
|
|
|
|
"/mpd/mpd.conf"))
|
|
|
|
"~/.mpdconf" "~/.mpd/mpd.conf" "/etc/mpd.conf"))
|
2009-12-01 04:04:33 +00:00
|
|
|
file)
|
|
|
|
(while (and files (not file))
|
|
|
|
(if (file-exists-p (car files)) (setq file (car files)))
|
|
|
|
(setq files (cdr files)))
|
|
|
|
(with-temp-buffer
|
|
|
|
(ignore-errors (insert-file-contents file))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (re-search-forward "^music_directory[ ]+\"\\([^\"]+\\)\"")
|
|
|
|
(setq mpc-mpd-music-directory
|
|
|
|
(match-string 1))))))
|
|
|
|
;; Use mpc-mpd-music-directory if applicable, or else try to use the
|
|
|
|
;; `download' command, although it's never been accepted in `mpd' :-(
|
|
|
|
(if (and mpc-mpd-music-directory
|
|
|
|
(file-exists-p (expand-file-name file mpc-mpd-music-directory)))
|
|
|
|
(expand-file-name file mpc-mpd-music-directory)
|
|
|
|
;; (let ((aux (expand-file-name (replace-regexp-in-string "[/]" "|" file)
|
|
|
|
;; (mpc-data-directory))))
|
|
|
|
;; (unless (file-exists-p aux)
|
|
|
|
;; (condition-case err
|
|
|
|
;; (with-local-quit
|
|
|
|
;; (with-current-buffer (mpc-cmd-download file)
|
|
|
|
;; (write-region (point-min) (point-max) aux)
|
|
|
|
;; (kill-buffer (current-buffer))))
|
|
|
|
;; (mpc-proc-error (message "Download error: %s" err) (setq aux nil))))
|
|
|
|
;; aux)
|
|
|
|
))
|
|
|
|
|
|
|
|
;;; Formatter ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2021-09-29 05:12:37 +00:00
|
|
|
(defcustom mpc-cover-image-re nil ; (rx (or ".jpg" ".jpeg" ".png") string-end)
|
|
|
|
"If non-nil, it is a regexp that should match a valid cover image."
|
2021-10-01 15:33:32 +00:00
|
|
|
:type '(choice (const nil) regexp)
|
2021-09-29 05:12:37 +00:00
|
|
|
:version "28.1")
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-secs-to-time (secs)
|
2010-03-25 00:06:08 +00:00
|
|
|
;; We could use `format-seconds', but it doesn't seem worth the trouble
|
|
|
|
;; because we'd still need to check (>= secs (* 60 100)) since the special
|
|
|
|
;; %z only allows us to drop the large units for small values but
|
|
|
|
;; not to drop the small units for large values.
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (stringp secs) (setq secs (string-to-number secs)))
|
|
|
|
(if (>= secs (* 60 100)) ;More than 100 minutes.
|
|
|
|
(format "%dh%02d" ;"%d:%02d:%02d"
|
|
|
|
(/ secs 3600) (% (/ secs 60) 60)) ;; (% secs 60)
|
|
|
|
(format "%d:%02d" (/ secs 60) (% secs 60))))
|
|
|
|
|
|
|
|
(defvar mpc-tempfiles nil)
|
|
|
|
(defconst mpc-tempfiles-reftable (make-hash-table :weakness 'key))
|
|
|
|
|
|
|
|
(defun mpc-tempfiles-clean ()
|
|
|
|
(let ((live ()))
|
2011-03-01 05:03:24 +00:00
|
|
|
(maphash (lambda (_k v) (push v live)) mpc-tempfiles-reftable)
|
2009-12-01 04:04:33 +00:00
|
|
|
(dolist (f mpc-tempfiles)
|
|
|
|
(unless (member f live) (ignore-errors (delete-file f))))
|
|
|
|
(setq mpc-tempfiles live)))
|
|
|
|
|
|
|
|
(defun mpc-tempfiles-add (key file)
|
|
|
|
(mpc-tempfiles-clean)
|
|
|
|
(puthash key file mpc-tempfiles-reftable)
|
|
|
|
(push file mpc-tempfiles))
|
|
|
|
|
|
|
|
(defun mpc-format (format-spec info &optional hscroll)
|
|
|
|
"Format the INFO according to FORMAT-SPEC, inserting the result at point."
|
|
|
|
(let* ((pos 0)
|
|
|
|
(start (point))
|
|
|
|
(col (if hscroll (- hscroll) 0))
|
|
|
|
(insert (lambda (str)
|
|
|
|
(cond
|
|
|
|
((>= col 0) (insert str))
|
|
|
|
(t (insert (substring str (min (length str) (- col))))))))
|
2021-04-24 19:57:22 +00:00
|
|
|
(pred #'always))
|
2009-12-01 04:04:33 +00:00
|
|
|
(while (string-match "%\\(?:%\\|\\(-\\)?\\([0-9]+\\)?{\\([[:alpha:]][[:alnum:]]*\\)\\(?:-\\([^}]+\\)\\)?}\\)" format-spec pos)
|
|
|
|
(let ((pre-text (substring format-spec pos (match-beginning 0))))
|
|
|
|
(funcall insert pre-text)
|
|
|
|
(setq col (+ col (string-width pre-text))))
|
|
|
|
(setq pos (match-end 0))
|
|
|
|
(if (null (match-end 3))
|
|
|
|
(progn
|
|
|
|
(funcall insert "%")
|
|
|
|
(setq col (+ col 1)))
|
|
|
|
(let* ((size (match-string 2 format-spec))
|
|
|
|
(tag (intern (match-string 3 format-spec)))
|
|
|
|
(post (match-string 4 format-spec))
|
|
|
|
(right-align (match-end 1))
|
|
|
|
(text
|
|
|
|
(if (eq info 'self) (symbol-name tag)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(pcase tag
|
2018-11-05 00:22:15 +00:00
|
|
|
((or 'Time 'Duration)
|
2009-12-01 04:04:33 +00:00
|
|
|
(let ((time (cdr (or (assq 'time info) (assq 'Time info)))))
|
2021-04-24 19:57:22 +00:00
|
|
|
(setq pred #'ignore) ;Just assume it's never eq.
|
2009-12-01 04:04:33 +00:00
|
|
|
(when time
|
|
|
|
(mpc-secs-to-time (if (and (eq tag 'Duration)
|
|
|
|
(string-match ":" time))
|
|
|
|
(substring time (match-end 0))
|
|
|
|
time)))))
|
2018-11-05 00:22:15 +00:00
|
|
|
('Cover
|
2015-11-18 18:42:40 +00:00
|
|
|
(let ((dir (file-name-directory (cdr (assq 'file info)))))
|
2015-10-14 23:00:31 +00:00
|
|
|
;; (debug)
|
2021-04-24 19:57:22 +00:00
|
|
|
(setq pred
|
2021-05-29 18:24:23 +00:00
|
|
|
;; We want the closure to capture the current
|
|
|
|
;; value of `pred' and not a reference to the
|
|
|
|
;; variable itself.
|
|
|
|
(let ((oldpred pred))
|
|
|
|
(lambda (info)
|
|
|
|
(and (funcall oldpred info)
|
|
|
|
(equal dir (file-name-directory
|
|
|
|
(cdr (assq 'file info))))))))
|
2021-09-29 05:12:37 +00:00
|
|
|
(if-let* ((covers '(".folder.png" "folder.png" "cover.jpg" "folder.jpg"))
|
2017-09-12 17:08:47 +00:00
|
|
|
(cover (cl-loop for file in (directory-files (mpc-file-local-copy dir))
|
2021-09-29 05:12:37 +00:00
|
|
|
if (or (member (downcase file) covers)
|
|
|
|
(and mpc-cover-image-re
|
|
|
|
(string-match mpc-cover-image-re file)))
|
2017-09-12 17:08:47 +00:00
|
|
|
return (concat dir file)))
|
|
|
|
(file (with-demoted-errors "MPC: %s"
|
|
|
|
(mpc-file-local-copy cover))))
|
2015-10-14 23:00:31 +00:00
|
|
|
(let (image)
|
|
|
|
(if (null size) (setq image (create-image file))
|
|
|
|
(let ((tempfile (make-temp-file "mpc" nil ".jpg")))
|
2021-09-29 05:12:37 +00:00
|
|
|
;; FIXME: Use native image scaling instead.
|
2015-10-14 23:00:31 +00:00
|
|
|
(call-process "convert" nil nil nil
|
|
|
|
"-scale" size file tempfile)
|
|
|
|
(setq image (create-image tempfile))
|
|
|
|
(mpc-tempfiles-add image tempfile)))
|
|
|
|
(setq size nil)
|
|
|
|
(propertize dir 'display image))
|
|
|
|
;; Make sure we return something on which we can
|
2021-04-24 19:57:22 +00:00
|
|
|
;; place the `mpc--uptodate-p' property, as
|
2015-10-14 23:00:31 +00:00
|
|
|
;; a negative-cache. We could also use
|
|
|
|
;; a default cover.
|
|
|
|
(progn (setq size nil) " "))))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(_ (let ((val (cdr (assq tag info))))
|
2009-12-01 04:04:33 +00:00
|
|
|
;; For Streaming URLs, there's no other info
|
|
|
|
;; than the URL in `file'. Pretend it's in `Title'.
|
|
|
|
(when (and (null val) (eq tag 'Title))
|
|
|
|
(setq val (cdr (assq 'file info))))
|
2021-04-24 19:57:22 +00:00
|
|
|
(setq pred
|
2021-05-29 18:24:23 +00:00
|
|
|
;; We want the closure to capture the current
|
|
|
|
;; value of `pred' and not a reference to the
|
|
|
|
;; variable itself.
|
|
|
|
(let ((oldpred pred))
|
|
|
|
(lambda (info)
|
|
|
|
(and (funcall oldpred info)
|
|
|
|
(equal val (cdr (assq tag info)))))))
|
2014-05-12 13:25:53 +00:00
|
|
|
(cond
|
|
|
|
((not (and (eq tag 'Date) (stringp val))) val)
|
|
|
|
;; For "date", only keep the year!
|
|
|
|
((string-match "[0-9]\\{4\\}" val)
|
|
|
|
(match-string 0 val))
|
|
|
|
(t val)))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(space (when size
|
|
|
|
(setq size (string-to-number size))
|
|
|
|
(propertize " " 'display
|
|
|
|
(list 'space :align-to (+ col size)))))
|
|
|
|
(textwidth (if text (string-width text) 0))
|
|
|
|
(postwidth (if post (string-width post) 0)))
|
|
|
|
(when text
|
|
|
|
(let ((display
|
|
|
|
(if (and size
|
|
|
|
(> (+ postwidth textwidth) size))
|
|
|
|
(propertize
|
2012-12-12 14:42:03 +00:00
|
|
|
(truncate-string-to-width text size nil nil "…")
|
2009-12-01 04:04:33 +00:00
|
|
|
'help-echo text)
|
|
|
|
text)))
|
|
|
|
(when (memq tag '(Artist Album Composer)) ;FIXME: wrong list.
|
|
|
|
(setq display
|
|
|
|
(propertize display
|
|
|
|
'mouse-face 'highlight
|
|
|
|
'follow-link t
|
|
|
|
'keymap `(keymap
|
|
|
|
(mouse-2
|
2021-04-24 19:57:22 +00:00
|
|
|
. ,(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(mpc-constraints-push 'noerror)
|
|
|
|
(mpc-constraints-restore
|
|
|
|
',(list (list tag text)))))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(funcall insert
|
|
|
|
(concat (when size
|
|
|
|
(propertize " " 'display
|
|
|
|
(list 'space :align-to
|
|
|
|
(+ col
|
|
|
|
(if (and size right-align)
|
|
|
|
(- size postwidth textwidth)
|
|
|
|
0)))))
|
|
|
|
display post))))
|
|
|
|
(if (null size) (setq col (+ col textwidth postwidth))
|
|
|
|
(insert space)
|
|
|
|
(setq col (+ col size))))))
|
2021-09-29 04:54:52 +00:00
|
|
|
;; Print the rest of format-spec, in case there is text after the
|
|
|
|
;; last actual format specifier.
|
|
|
|
(insert (substring format-spec pos))
|
2021-04-24 19:57:22 +00:00
|
|
|
(put-text-property start (point) 'mpc--uptodate-p pred)))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
;;; The actual UI code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2022-07-17 10:56:38 +00:00
|
|
|
(defvar-keymap mpc-mode-map
|
|
|
|
;; "ESC" #'mpc-stop
|
|
|
|
"q" #'mpc-quit
|
|
|
|
"RET" #'mpc-select
|
|
|
|
"S-<return>" #'mpc-select-toggle
|
|
|
|
"<mouse-2>" #'mpc-select
|
|
|
|
"S-<mouse-2>" #'mpc-select-extend
|
|
|
|
"C-<mouse-2>" #'mpc-select-toggle
|
|
|
|
"<drag-mouse-2>" #'mpc-drag-n-drop
|
|
|
|
;; We use `always' because a binding to t is like a binding to nil.
|
|
|
|
"<follow-link>" :always
|
|
|
|
;; But follow-link doesn't apply blindly to header-line and
|
|
|
|
;; mode-line clicks.
|
|
|
|
"<header-line> <follow-link>" #'ignore
|
|
|
|
"<mode-line> <follow-link>" #'ignore
|
|
|
|
;; Doesn't work because the first click changes the buffer, so the second
|
|
|
|
;; is applied elsewhere :-(
|
|
|
|
;; "<double-mouse-2>" #'mpc-play-at-point
|
|
|
|
"p" #'mpc-pause
|
|
|
|
"s" #'mpc-toggle-play
|
|
|
|
">" #'mpc-next
|
|
|
|
"<" #'mpc-prev
|
|
|
|
"g" #'mpc-seek-current
|
|
|
|
"o" #'mpc-goto-playing-song)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(easy-menu-define mpc-mode-menu mpc-mode-map
|
2017-04-27 04:04:54 +00:00
|
|
|
"Menu for MPC mode."
|
|
|
|
'("MPC"
|
2015-10-16 13:56:05 +00:00
|
|
|
["Play/Pause" mpc-toggle-play] ;FIXME: Add one of ⏯/▶/⏸ in there?
|
|
|
|
["Next Track" mpc-next] ;FIXME: Add ⇥ there?
|
|
|
|
["Previous Track" mpc-prev] ;FIXME: Add ⇤ there?
|
2015-11-18 18:46:24 +00:00
|
|
|
["Seek Within Track" mpc-seek-current]
|
2015-10-15 16:32:59 +00:00
|
|
|
"--"
|
2015-10-16 13:56:05 +00:00
|
|
|
["Repeat Playlist" mpc-toggle-repeat :style toggle
|
2015-10-15 16:32:59 +00:00
|
|
|
:selected (member '(repeat . "1") mpc-status)]
|
2015-10-16 13:56:05 +00:00
|
|
|
["Shuffle Playlist" mpc-toggle-shuffle :style toggle
|
2015-10-15 16:32:59 +00:00
|
|
|
:selected (member '(random . "1") mpc-status)]
|
2015-10-16 13:56:05 +00:00
|
|
|
["Repeat Single Track" mpc-toggle-single :style toggle
|
2015-10-15 16:32:59 +00:00
|
|
|
:selected (member '(single . "1") mpc-status)]
|
2015-10-16 13:56:05 +00:00
|
|
|
["Consume Mode" mpc-toggle-consume :style toggle
|
2015-10-15 16:32:59 +00:00
|
|
|
:selected (member '(consume . "1") mpc-status)]
|
|
|
|
"--"
|
2009-12-01 04:04:33 +00:00
|
|
|
["Add new browser" mpc-tagbrowser]
|
|
|
|
["Update DB" mpc-update]
|
|
|
|
["Quit" mpc-quit]))
|
|
|
|
|
|
|
|
(defvar mpc-tool-bar-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(tool-bar-local-item "mpc/prev" 'mpc-prev 'prev map
|
2011-10-05 00:56:26 +00:00
|
|
|
:enable '(not (equal (cdr (assq 'state mpc-status)) "stop"))
|
|
|
|
:label "Prev" :vert-only t)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; FIXME: how can we bind it to the down-event?
|
|
|
|
(tool-bar-local-item "mpc/rewind" 'mpc-rewind 'rewind map
|
|
|
|
:enable '(not (equal (cdr (assq 'state mpc-status)) "stop"))
|
2011-10-05 00:56:26 +00:00
|
|
|
:label "Rew" :vert-only t
|
2009-12-01 04:04:33 +00:00
|
|
|
:button '(:toggle . (and mpc--faster-toggle-timer
|
|
|
|
(not mpc--faster-toggle-forward))))
|
|
|
|
;; We could use a single toggle command for pause/play, with 2 different
|
|
|
|
;; icons depending on whether or not it's selected, but then it'd have
|
|
|
|
;; to be a toggle-button, thus displayed depressed in one of the
|
|
|
|
;; two states :-(
|
|
|
|
(tool-bar-local-item "mpc/pause" 'mpc-pause 'pause map
|
2011-10-05 00:56:26 +00:00
|
|
|
:label "Pause" :vert-only t
|
2009-12-01 04:04:33 +00:00
|
|
|
:visible '(equal (cdr (assq 'state mpc-status)) "play")
|
|
|
|
:help "Pause/play")
|
|
|
|
(tool-bar-local-item "mpc/play" 'mpc-play 'play map
|
2011-10-05 00:56:26 +00:00
|
|
|
:label "Play" :vert-only t
|
2009-12-01 04:04:33 +00:00
|
|
|
:visible '(not (equal (cdr (assq 'state mpc-status)) "play"))
|
|
|
|
:help "Play/pause")
|
|
|
|
;; FIXME: how can we bind it to the down-event?
|
|
|
|
(tool-bar-local-item "mpc/ffwd" 'mpc-ffwd 'ffwd map
|
|
|
|
:enable '(not (equal (cdr (assq 'state mpc-status)) "stop"))
|
2011-10-05 00:56:26 +00:00
|
|
|
:label "Ffwd" :vert-only t
|
2009-12-01 04:04:33 +00:00
|
|
|
:button '(:toggle . (and mpc--faster-toggle-timer
|
|
|
|
mpc--faster-toggle-forward)))
|
|
|
|
(tool-bar-local-item "mpc/next" 'mpc-next 'next map
|
2011-10-05 00:56:26 +00:00
|
|
|
:label "Next" :vert-only t
|
2009-12-01 04:04:33 +00:00
|
|
|
:enable '(not (equal (cdr (assq 'state mpc-status)) "stop")))
|
2011-10-05 00:56:26 +00:00
|
|
|
(tool-bar-local-item "mpc/stop" 'mpc-stop 'stop map
|
|
|
|
:label "Stop" :vert-only t)
|
2009-12-01 04:04:33 +00:00
|
|
|
(tool-bar-local-item "mpc/add" 'mpc-playlist-add 'add map
|
2011-10-05 00:56:26 +00:00
|
|
|
:label "Add" :vert-only t
|
2009-12-01 04:04:33 +00:00
|
|
|
:help "Append to the playlist")
|
|
|
|
map))
|
|
|
|
|
2015-10-13 22:14:49 +00:00
|
|
|
(define-derived-mode mpc-mode special-mode "MPC"
|
2009-12-01 04:04:33 +00:00
|
|
|
"Major mode for the features common to all buffers of MPC."
|
|
|
|
(buffer-disable-undo)
|
2013-09-18 04:44:20 +00:00
|
|
|
(if (boundp 'tool-bar-map) ; not if --without-x
|
|
|
|
(setq-local tool-bar-map mpc-tool-bar-map))
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local truncate-lines t))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;;; The mpc-status-mode buffer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(define-derived-mode mpc-status-mode mpc-mode "MPC-Status"
|
|
|
|
"Major mode to display MPC status info."
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local mode-line-format
|
|
|
|
'("%e" mode-line-frame-identification
|
|
|
|
mode-line-buffer-identification))
|
|
|
|
(setq-local window-area-factor 3)
|
|
|
|
(setq-local header-line-format '("MPC " mpc-volume)))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defvar mpc-status-buffer-format
|
|
|
|
'("%-5{Time} / %{Duration} %2{Disc--}%4{Track}" "%{Title}" "%{Album}" "%{Artist}" "%128{Cover}"))
|
|
|
|
|
|
|
|
(defun mpc-status-buffer-refresh ()
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'status)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(when (assq 'file mpc-status)
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(dolist (spec mpc-status-buffer-format)
|
2021-04-24 19:57:22 +00:00
|
|
|
(let ((pred (get-text-property (point) 'mpc--uptodate-p)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (and pred (funcall pred mpc-status))
|
|
|
|
(forward-line)
|
|
|
|
(delete-region (point) (line-beginning-position 2))
|
|
|
|
(ignore-errors (mpc-format spec mpc-status))
|
|
|
|
(insert "\n"))))
|
|
|
|
(unless (eobp) (delete-region (point) (point-max))))))))))
|
|
|
|
|
|
|
|
(defun mpc-status-buffer-show ()
|
|
|
|
(interactive)
|
2013-04-10 13:17:27 +00:00
|
|
|
(let* ((proc (mpc-proc))
|
|
|
|
(buf (mpc-proc-buffer proc 'status))
|
|
|
|
(songs-buf (mpc-proc-buffer proc 'songs))
|
2009-12-01 04:04:33 +00:00
|
|
|
(songs-win (if songs-buf (get-buffer-window songs-buf 0))))
|
|
|
|
(unless (buffer-live-p buf)
|
|
|
|
(setq buf (get-buffer-create "*MPC-Status*"))
|
|
|
|
(with-current-buffer buf
|
|
|
|
(mpc-status-mode))
|
2013-04-10 13:17:27 +00:00
|
|
|
(mpc-proc-buffer proc 'status buf))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (null songs-win) (pop-to-buffer buf)
|
2011-03-01 05:03:24 +00:00
|
|
|
(let ((_win (split-window songs-win 20 t)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(set-window-dedicated-p songs-win nil)
|
|
|
|
(set-window-buffer songs-win buf)
|
|
|
|
(set-window-dedicated-p songs-win 'soft)))))
|
|
|
|
|
|
|
|
;;; Selection management;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defvar mpc-separator-ol nil)
|
|
|
|
|
2013-03-29 14:23:24 +00:00
|
|
|
(defvar-local mpc-select nil)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defmacro mpc-select-save (&rest body)
|
|
|
|
"Execute BODY and restore the selection afterwards."
|
|
|
|
(declare (indent 0) (debug t))
|
|
|
|
`(let ((selection (mpc-select-get-selection))
|
|
|
|
(position (cons (buffer-substring-no-properties
|
|
|
|
(line-beginning-position) (line-end-position))
|
|
|
|
(current-column))))
|
|
|
|
,@body
|
|
|
|
(mpc-select-restore selection)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (re-search-forward
|
|
|
|
(concat "^" (regexp-quote (car position)) "$")
|
|
|
|
(if (overlayp mpc-separator-ol)
|
|
|
|
(overlay-end mpc-separator-ol))
|
|
|
|
t)
|
|
|
|
(move-to-column (cdr position)))
|
|
|
|
(let ((win (get-buffer-window (current-buffer) 0)))
|
|
|
|
(if win (set-window-point win (point))))))
|
|
|
|
|
|
|
|
(defun mpc-select-get-selection ()
|
|
|
|
(mapcar (lambda (ol)
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
(overlay-start ol) (1- (overlay-end ol))))
|
|
|
|
mpc-select))
|
|
|
|
|
|
|
|
(defun mpc-select-restore (selection)
|
|
|
|
;; Restore the selection. I.e. move the overlays back to their
|
|
|
|
;; corresponding location. Actually which overlay is used for what
|
|
|
|
;; doesn't matter.
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapc #'delete-overlay mpc-select)
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq mpc-select nil)
|
|
|
|
(dolist (elem selection)
|
|
|
|
;; After an update, some elements may have disappeared.
|
|
|
|
(goto-char (point-min))
|
|
|
|
(when (re-search-forward
|
|
|
|
(concat "^" (regexp-quote elem) "$") nil t)
|
|
|
|
(mpc-select-make-overlay)))
|
|
|
|
(when mpc-tag (mpc-tagbrowser-all-select))
|
|
|
|
(beginning-of-line))
|
|
|
|
|
|
|
|
(defun mpc-select-make-overlay ()
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-assert (not (get-char-property (point) 'mpc-select)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(let ((ol (make-overlay
|
|
|
|
(line-beginning-position) (line-beginning-position 2))))
|
|
|
|
(overlay-put ol 'mpc-select t)
|
2015-10-12 20:46:29 +00:00
|
|
|
(overlay-put ol 'face 'highlight)
|
2009-12-01 04:04:33 +00:00
|
|
|
(overlay-put ol 'evaporate t)
|
|
|
|
(push ol mpc-select)))
|
|
|
|
|
|
|
|
(defun mpc-select (&optional event)
|
|
|
|
"Select the tag value at point."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(mpc-event-set-point event)
|
|
|
|
(if (and (bolp) (eobp)) (forward-line -1))
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapc #'delete-overlay mpc-select)
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq mpc-select nil)
|
|
|
|
(if (mpc-tagbrowser-all-p)
|
|
|
|
nil
|
|
|
|
(mpc-select-make-overlay))
|
|
|
|
(when mpc-tag
|
|
|
|
(mpc-tagbrowser-all-select)
|
|
|
|
(mpc-selection-refresh)))
|
|
|
|
|
|
|
|
(defun mpc-select-toggle (&optional event)
|
|
|
|
"Toggle the selection of the tag value at point."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(mpc-event-set-point event)
|
|
|
|
(save-excursion
|
|
|
|
(cond
|
|
|
|
;; The line is already selected: deselect it.
|
|
|
|
((get-char-property (point) 'mpc-select)
|
|
|
|
(let ((ols nil))
|
|
|
|
(dolist (ol mpc-select)
|
|
|
|
(if (and (<= (overlay-start ol) (point))
|
|
|
|
(> (overlay-end ol) (point)))
|
|
|
|
(delete-overlay ol)
|
|
|
|
(push ol ols)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-assert (= (1+ (length ols)) (length mpc-select)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq mpc-select ols)))
|
|
|
|
;; We're trying to select *ALL* additionally to others.
|
|
|
|
((mpc-tagbrowser-all-p) nil)
|
|
|
|
;; Select the current line.
|
|
|
|
(t (mpc-select-make-overlay))))
|
|
|
|
(when mpc-tag
|
|
|
|
(mpc-tagbrowser-all-select)
|
|
|
|
(mpc-selection-refresh)))
|
|
|
|
|
|
|
|
(defun mpc-select-extend (&optional event)
|
|
|
|
"Extend the selection up to point."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(mpc-event-set-point event)
|
|
|
|
(if (null mpc-select)
|
|
|
|
;; If nothing's selected yet, fallback to selecting the elem at point.
|
|
|
|
(mpc-select event)
|
|
|
|
(save-excursion
|
|
|
|
(cond
|
|
|
|
;; The line is already in a selected area; truncate the area.
|
|
|
|
((get-char-property (point) 'mpc-select)
|
|
|
|
(let ((before 0)
|
|
|
|
(after 0)
|
|
|
|
(mid (line-beginning-position))
|
|
|
|
start end)
|
|
|
|
(while (and (zerop (forward-line 1))
|
|
|
|
(get-char-property (point) 'mpc-select))
|
|
|
|
(setq end (1+ (point)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf after))
|
2009-12-01 04:04:33 +00:00
|
|
|
(goto-char mid)
|
|
|
|
(while (and (zerop (forward-line -1))
|
|
|
|
(get-char-property (point) 'mpc-select))
|
|
|
|
(setq start (point))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf before))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (and (= after 0) (= before 0))
|
|
|
|
;; Shortening an already minimum-size region: do nothing.
|
|
|
|
nil
|
|
|
|
(if (> after before)
|
|
|
|
(setq end mid)
|
|
|
|
(setq start (1+ mid)))
|
|
|
|
(let ((ols '()))
|
|
|
|
(dolist (ol mpc-select)
|
|
|
|
(if (and (>= (overlay-start ol) start)
|
|
|
|
(< (overlay-start ol) end))
|
|
|
|
(delete-overlay ol)
|
|
|
|
(push ol ols)))
|
|
|
|
(setq mpc-select (nreverse ols))))))
|
|
|
|
;; Extending a prior area. Look for the closest selection.
|
|
|
|
(t
|
|
|
|
(when (mpc-tagbrowser-all-p)
|
|
|
|
(forward-line 1))
|
|
|
|
(let ((before 0)
|
|
|
|
(count 0)
|
|
|
|
(dir 1)
|
|
|
|
(start (line-beginning-position)))
|
|
|
|
(while (and (zerop (forward-line 1))
|
|
|
|
(not (get-char-property (point) 'mpc-select)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf count))
|
2009-12-01 04:04:33 +00:00
|
|
|
(unless (get-char-property (point) 'mpc-select)
|
|
|
|
(setq count nil))
|
|
|
|
(goto-char start)
|
|
|
|
(while (and (zerop (forward-line -1))
|
|
|
|
(not (get-char-property (point) 'mpc-select)))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf before))
|
2009-12-01 04:04:33 +00:00
|
|
|
(unless (get-char-property (point) 'mpc-select)
|
|
|
|
(setq before nil))
|
|
|
|
(when (and before (or (null count) (< before count)))
|
|
|
|
(setq count before)
|
|
|
|
(setq dir -1))
|
|
|
|
(goto-char start)
|
2011-06-02 11:24:12 +00:00
|
|
|
(dotimes (_i (1+ (or count 0)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-select-make-overlay)
|
|
|
|
(forward-line dir))))))
|
|
|
|
(when mpc-tag
|
|
|
|
(mpc-tagbrowser-all-select)
|
|
|
|
(mpc-selection-refresh))))
|
|
|
|
|
|
|
|
;;; Constraint sets ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defvar mpc--song-search nil)
|
|
|
|
|
|
|
|
(defun mpc-constraints-get-current (&optional avoid-buf)
|
|
|
|
"Return currently selected set of constraints.
|
|
|
|
If AVOID-BUF is non-nil, it specifies a buffer which should be ignored
|
|
|
|
when constructing the set of constraints."
|
|
|
|
(let ((constraints (if mpc--song-search `((Search ,mpc--song-search))))
|
|
|
|
tag select)
|
|
|
|
(dolist (buf (process-get (mpc-proc) 'buffers))
|
|
|
|
(setq buf (cdr buf))
|
|
|
|
(when (and (setq tag (buffer-local-value 'mpc-tag buf))
|
|
|
|
(not (eq buf avoid-buf))
|
|
|
|
(setq select
|
|
|
|
(with-current-buffer buf (mpc-select-get-selection))))
|
|
|
|
(push (cons tag select) constraints)))
|
|
|
|
constraints))
|
|
|
|
|
2011-09-14 21:20:24 +00:00
|
|
|
(defun mpc-constraints-tag-lookup (buffer-tag constraints)
|
|
|
|
(let (res)
|
|
|
|
(dolist (constraint constraints)
|
|
|
|
(when (or (eq (car constraint) buffer-tag)
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
(and (string-search "|" (symbol-name buffer-tag))
|
2011-09-14 21:20:24 +00:00
|
|
|
(member (symbol-name (car constraint))
|
|
|
|
(split-string (symbol-name buffer-tag) "|"))))
|
|
|
|
(setq res (cdr constraint))))
|
|
|
|
res))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-constraints-restore (constraints)
|
|
|
|
(let ((search (assq 'Search constraints)))
|
|
|
|
(setq mpc--song-search (cadr search))
|
|
|
|
(when search (setq constraints (delq search constraints))))
|
|
|
|
(dolist (buf (process-get (mpc-proc) 'buffers))
|
|
|
|
(setq buf (cdr buf))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(let* ((tag (buffer-local-value 'mpc-tag buf))
|
2011-09-14 21:20:24 +00:00
|
|
|
(constraint (mpc-constraints-tag-lookup tag constraints)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(when tag
|
|
|
|
(with-current-buffer buf
|
2011-09-14 21:20:24 +00:00
|
|
|
(mpc-select-restore constraint))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-selection-refresh))
|
|
|
|
|
|
|
|
;; I don't get the ring.el code. I think it doesn't do what I need, but
|
|
|
|
;; then I don't understand when what it does would be useful.
|
|
|
|
(defun mpc-ring-make (size) (cons 0 (cons 0 (make-vector size nil))))
|
|
|
|
(defun mpc-ring-push (ring val)
|
|
|
|
(aset (cddr ring) (car ring) val)
|
|
|
|
(setcar (cdr ring) (max (cadr ring) (1+ (car ring))))
|
|
|
|
(setcar ring (mod (1+ (car ring)) (length (cddr ring)))))
|
|
|
|
(defun mpc-ring-pop (ring)
|
|
|
|
(setcar ring (mod (1- (car ring)) (cadr ring)))
|
|
|
|
(aref (cddr ring) (car ring)))
|
|
|
|
|
|
|
|
(defvar mpc-constraints-ring (mpc-ring-make 10))
|
|
|
|
|
|
|
|
(defun mpc-constraints-push (&optional noerror)
|
|
|
|
"Push the current selection on the ring for later."
|
|
|
|
(interactive)
|
|
|
|
(let ((constraints (mpc-constraints-get-current)))
|
|
|
|
(if (null constraints)
|
|
|
|
(unless noerror (error "No selection to push"))
|
|
|
|
(mpc-ring-push mpc-constraints-ring constraints))))
|
|
|
|
|
|
|
|
(defun mpc-constraints-pop ()
|
|
|
|
"Recall the most recently pushed selection."
|
|
|
|
(interactive)
|
|
|
|
(let ((constraints (mpc-ring-pop mpc-constraints-ring)))
|
|
|
|
(if (null constraints)
|
|
|
|
(error "No selection to return to")
|
|
|
|
(mpc-constraints-restore constraints))))
|
|
|
|
|
|
|
|
;;; The TagBrowser mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defconst mpc-tagbrowser-all-name (propertize "*ALL*" 'face 'italic))
|
2013-03-29 14:23:24 +00:00
|
|
|
(defvar-local mpc-tagbrowser-all-ol nil)
|
|
|
|
(defvar-local mpc-tag-name nil)
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-tagbrowser-all-p ()
|
|
|
|
(and (eq (point-min) (line-beginning-position))
|
|
|
|
(equal mpc-tagbrowser-all-name
|
|
|
|
(buffer-substring (point-min) (line-end-position)))))
|
|
|
|
|
|
|
|
(define-derived-mode mpc-tagbrowser-mode mpc-mode '("MPC-" mpc-tag-name)
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local mode-line-process '("" mpc-tag-name))
|
|
|
|
(setq-local mode-line-format nil)
|
|
|
|
(setq-local header-line-format '("" mpc-tag-name)) ;; "s"
|
|
|
|
(setq-local buffer-undo-list t)
|
2009-12-01 04:04:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
(defun mpc-tagbrowser-refresh ()
|
|
|
|
(mpc-select-save
|
|
|
|
(widen)
|
|
|
|
(goto-char (point-min))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-assert (looking-at (regexp-quote mpc-tagbrowser-all-name)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(forward-line 1)
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(delete-region (point) (point-max))
|
|
|
|
(dolist (val (mpc-cmd-list mpc-tag)) (insert val "\n")))
|
|
|
|
(set-buffer-modified-p nil))
|
|
|
|
(mpc-reorder))
|
|
|
|
|
|
|
|
(defun mpc-updated-db ()
|
|
|
|
;; FIXME: This is not asynchronous, but is run from a process filter.
|
|
|
|
(unless (assq 'updating_db mpc-status)
|
|
|
|
(clrhash mpc--find-memoize)
|
|
|
|
(dolist (buf (process-get (mpc-proc) 'buffers))
|
|
|
|
(setq buf (cdr buf))
|
|
|
|
(when (buffer-local-value 'mpc-tag buf)
|
|
|
|
(with-current-buffer buf (with-local-quit (mpc-tagbrowser-refresh)))))
|
|
|
|
(with-local-quit (mpc-songs-refresh))))
|
|
|
|
|
2010-03-25 00:06:08 +00:00
|
|
|
(defun mpc-tagbrowser-tag-name (tag)
|
|
|
|
(cond
|
|
|
|
((string-match "|" (symbol-name tag))
|
|
|
|
(let ((tag1 (intern (substring (symbol-name tag)
|
|
|
|
0 (match-beginning 0))))
|
|
|
|
(tag2 (intern (substring (symbol-name tag)
|
|
|
|
(match-end 0)))))
|
|
|
|
(concat (mpc-tagbrowser-tag-name tag1)
|
|
|
|
" | "
|
|
|
|
(mpc-tagbrowser-tag-name tag2))))
|
|
|
|
((string-match "y\\'" (symbol-name tag))
|
|
|
|
(concat (substring (symbol-name tag) 0 -1) "ies"))
|
|
|
|
(t (concat (symbol-name tag) "s"))))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-tagbrowser-buf (tag)
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) tag)))
|
|
|
|
(if (buffer-live-p buf) buf
|
|
|
|
(setq buf (get-buffer-create (format "*MPC %ss*" tag)))
|
|
|
|
(mpc-proc-buffer (mpc-proc) tag buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(erase-buffer)
|
|
|
|
(if (member tag '(Directory))
|
|
|
|
(mpc-tagbrowser-dir-mode)
|
|
|
|
(mpc-tagbrowser-mode))
|
|
|
|
(insert mpc-tagbrowser-all-name "\n"))
|
|
|
|
(forward-line -1)
|
|
|
|
(setq mpc-tag tag)
|
2010-03-25 00:06:08 +00:00
|
|
|
(setq mpc-tag-name (mpc-tagbrowser-tag-name tag))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-tagbrowser-all-select)
|
|
|
|
(mpc-tagbrowser-refresh)
|
|
|
|
buf))))
|
|
|
|
|
2022-08-04 09:32:26 +00:00
|
|
|
(define-obsolete-variable-alias 'tag-browser-tagtypes 'mpc-tag-browser-tagtypes "29.1")
|
|
|
|
(defvar mpc-tag-browser-tagtypes
|
|
|
|
(lazy-completion-table mpc-tag-browser-tagtypes
|
2009-12-01 04:04:33 +00:00
|
|
|
(lambda ()
|
|
|
|
(append '("Playlist" "Directory")
|
|
|
|
(mpc-cmd-tagtypes)))))
|
|
|
|
|
|
|
|
(defun mpc-tagbrowser (tag)
|
|
|
|
"Create a new browser for TAG."
|
|
|
|
(interactive
|
|
|
|
(list
|
|
|
|
(let ((completion-ignore-case t))
|
|
|
|
(intern
|
2022-08-04 09:32:26 +00:00
|
|
|
(completing-read "Tag: " mpc-tag-browser-tagtypes nil 'require-match)))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(let* ((newbuf (mpc-tagbrowser-buf tag))
|
|
|
|
(win (get-buffer-window newbuf 0)))
|
|
|
|
(if win (select-window win)
|
Do not call to `selected-window' where it is assumed by default.
Affected functions are `window-minibuffer-p', `window-dedicated-p',
`window-hscroll', `window-width', `window-height', `window-buffer',
`window-frame', `window-start', `window-point', `next-window'
and `window-display-table'.
* abbrev.el (abbrev--default-expand):
* bs.el (bs--show-with-configuration):
* buff-menu.el (Buffer-menu-mouse-select):
* calc/calc.el (calc):
* calendar/calendar.el (calendar-generate-window):
* calendar/diary-lib.el (diary-simple-display, diary-show-all-entries)
(diary-make-entry):
* comint.el (send-invisible, comint-dynamic-complete-filename)
(comint-dynamic-simple-complete, comint-dynamic-list-completions):
* completion.el (complete):
* dabbrev.el (dabbrev-expand, dabbrev--make-friend-buffer-list):
* disp-table.el (describe-current-display-table):
* doc-view.el (doc-view-insert-image):
* ebuff-menu.el (Electric-buffer-menu-mouse-select):
* ehelp.el (with-electric-help):
* emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* emacs-lisp/edebug.el (edebug-two-window-p, edebug-pop-to-buffer):
* emacs-lisp/helper.el (Helper-help-scroller):
* emulation/cua-base.el (cua--post-command-handler-1):
* eshell/esh-mode.el (eshell-output-filter):
* ffap.el (ffap-gnus-wrapper):
* help-macro.el (make-help-screen):
* hilit-chg.el (highlight-compare-buffers):
* hippie-exp.el (hippie-expand, try-expand-dabbrev-visible):
* hl-line.el (global-hl-line-highlight):
* icomplete.el (icomplete-simple-completing-p):
* isearch.el (isearch-done):
* jit-lock.el (jit-lock-stealth-fontify):
* mail/rmailsum.el (rmail-summary-scroll-msg-up):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* mpc.el (mpc-tagbrowser, mpc):
* net/rcirc.el (rcirc-any-buffer):
* play/gomoku.el (gomoku-max-width, gomoku-max-height):
* play/landmark.el (landmark-max-width, landmark-max-height):
* play/zone.el (zone):
* progmodes/compile.el (compilation-goto-locus):
* progmodes/ebrowse.el (ebrowse-view/find-file-and-search-pattern):
* progmodes/etags.el (find-tag-other-window):
* progmodes/fortran.el (fortran-column-ruler):
* progmodes/gdb-mi.el (gdb-mouse-toggle-breakpoint-fringe):
* progmodes/verilog-mode.el (verilog-point-text):
* reposition.el (reposition-window):
* rot13.el (toggle-rot13-mode):
* server.el (server-switch-buffer):
* shell.el (shell-dynamic-complete-command)
(shell-dynamic-complete-environment-variable):
* simple.el (insert-buffer, set-selective-display)
(delete-completion-window):
* speedbar.el (speedbar-timer-fn, speedbar-center-buffer-smartly)
(speedbar-recenter):
* startup.el (fancy-splash-head):
* textmodes/ispell.el (ispell-command-loop):
* textmodes/makeinfo.el (makeinfo-compilation-sentinel-region):
* tutorial.el (help-with-tutorial):
* vc/add-log.el (add-change-log-entry):
* vc/compare-w.el (compare-windows):
* vc/ediff-help.el (ediff-indent-help-message):
* vc/ediff-util.el (ediff-setup-control-buffer, ediff-position-region):
* vc/ediff-wind.el (ediff-skip-unsuitable-frames)
(ediff-setup-control-frame):
* vc/emerge.el (emerge-position-region):
* vc/pcvs-util.el (cvs-bury-buffer):
* window.el (walk-windows, mouse-autoselect-window-select):
* winner.el (winner-set-conf, winner-undo): Related users changed.
2013-08-05 14:26:57 +00:00
|
|
|
(if (with-current-buffer (window-buffer)
|
2009-12-01 04:04:33 +00:00
|
|
|
(derived-mode-p 'mpc-tagbrowser-mode))
|
|
|
|
(setq win (selected-window))
|
|
|
|
;; Find a tagbrowser-mode buffer.
|
|
|
|
(let ((buffers (process-get (mpc-proc) 'buffers))
|
|
|
|
buffer)
|
|
|
|
(while
|
|
|
|
(and buffers
|
|
|
|
(not (and (buffer-live-p (setq buffer (cdr (pop buffers))))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(derived-mode-p 'mpc-tagbrowser-mode))
|
|
|
|
(setq win (get-buffer-window buffer 0))))))))
|
|
|
|
(if (not win)
|
|
|
|
(pop-to-buffer newbuf)
|
|
|
|
(setq win (split-window win nil 'horiz))
|
|
|
|
(set-window-buffer win newbuf)
|
|
|
|
(set-window-dedicated-p win 'soft)
|
|
|
|
(select-window win)
|
|
|
|
(balance-windows-area)))))
|
|
|
|
|
|
|
|
(defun mpc-tagbrowser-all-select ()
|
|
|
|
"Select the special *ALL* entry if no other is selected."
|
|
|
|
(if mpc-select
|
|
|
|
(delete-overlay mpc-tagbrowser-all-ol)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if mpc-tagbrowser-all-ol
|
|
|
|
(move-overlay mpc-tagbrowser-all-ol
|
|
|
|
(point) (line-beginning-position 2))
|
|
|
|
(let ((ol (make-overlay (point) (line-beginning-position 2))))
|
2015-10-12 20:46:29 +00:00
|
|
|
(overlay-put ol 'face 'highlight)
|
2009-12-01 04:04:33 +00:00
|
|
|
(overlay-put ol 'evaporate t)
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local mpc-tagbrowser-all-ol ol))))))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
;; (defvar mpc-constraints nil)
|
|
|
|
(defun mpc-separator (active)
|
|
|
|
;; Place a separator mark.
|
|
|
|
(unless mpc-separator-ol
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local mpc-separator-ol
|
|
|
|
(make-overlay (point) (point)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(overlay-put mpc-separator-ol 'after-string
|
|
|
|
(propertize "\n"
|
2019-11-27 16:19:30 +00:00
|
|
|
'face '(:height 0.05 :inverse-video t :extend t))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line 1)
|
|
|
|
(while
|
|
|
|
(and (member (buffer-substring-no-properties
|
|
|
|
(line-beginning-position) (line-end-position))
|
|
|
|
active)
|
|
|
|
(zerop (forward-line 1))))
|
|
|
|
(if (or (eobp) (null active))
|
|
|
|
(delete-overlay mpc-separator-ol)
|
|
|
|
(move-overlay mpc-separator-ol (1- (point)) (point))))
|
|
|
|
|
|
|
|
(defun mpc-sort (active)
|
|
|
|
;; Sort the active elements at the front.
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(if (mpc-tagbrowser-all-p) (forward-line 1))
|
|
|
|
(condition-case nil
|
|
|
|
(sort-subr nil 'forward-line 'end-of-line
|
|
|
|
nil nil
|
|
|
|
(lambda (s1 s2)
|
|
|
|
(setq s1 (buffer-substring-no-properties
|
|
|
|
(car s1) (cdr s1)))
|
|
|
|
(setq s2 (buffer-substring-no-properties
|
|
|
|
(car s2) (cdr s2)))
|
|
|
|
(cond
|
|
|
|
((member s1 active)
|
|
|
|
(if (member s2 active)
|
|
|
|
(let ((cmp (mpc-compare-strings s1 s2 t)))
|
|
|
|
(and (numberp cmp) (< cmp 0)))
|
|
|
|
t))
|
|
|
|
((member s2 active) nil)
|
|
|
|
(t (let ((cmp (mpc-compare-strings s1 s2 t)))
|
|
|
|
(and (numberp cmp) (< cmp 0)))))))
|
|
|
|
;; The comparison predicate arg is new in Emacs-22.
|
|
|
|
(wrong-number-of-arguments
|
|
|
|
(sort-subr nil 'forward-line 'end-of-line
|
|
|
|
(lambda ()
|
|
|
|
(let ((name (buffer-substring-no-properties
|
|
|
|
(point) (line-end-position))))
|
|
|
|
(cond
|
|
|
|
((member name active) (concat "1" name))
|
|
|
|
(t (concat "2" "name"))))))))))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defvar mpc--changed-selection)
|
|
|
|
|
|
|
|
(defun mpc-reorder (&optional nodeactivate)
|
2011-11-20 07:30:16 +00:00
|
|
|
"Reorder entries based on the currently active selections.
|
2009-12-01 04:04:33 +00:00
|
|
|
I.e. split the current browser buffer into a first part containing the
|
|
|
|
entries included in the selection, then a separator, and then the entries
|
|
|
|
not included in the selection.
|
|
|
|
Return non-nil if a selection was deactivated."
|
|
|
|
(mpc-select-save
|
|
|
|
(let ((constraints (mpc-constraints-get-current (current-buffer)))
|
|
|
|
(active 'all))
|
|
|
|
;; (unless (equal constraints mpc-constraints)
|
2013-03-29 14:23:24 +00:00
|
|
|
;; (setq-local mpc-constraints constraints)
|
2009-12-01 04:04:33 +00:00
|
|
|
(dolist (cst constraints)
|
2021-04-24 19:57:22 +00:00
|
|
|
(let ((vals (apply #'mpc-union
|
2009-12-01 04:04:33 +00:00
|
|
|
(mapcar (lambda (val)
|
|
|
|
(mpc-cmd-list mpc-tag (car cst) val))
|
|
|
|
(cdr cst)))))
|
|
|
|
(setq active
|
2021-04-04 23:13:54 +00:00
|
|
|
(if (listp active) (seq-intersection active vals) vals))))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2014-08-12 16:16:00 +00:00
|
|
|
(when (listp active)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; Remove the selections if they are all in conflict with
|
|
|
|
;; other constraints.
|
|
|
|
(let ((deactivate t))
|
|
|
|
(dolist (sel selection)
|
|
|
|
(when (member sel active) (setq deactivate nil)))
|
|
|
|
(when deactivate
|
|
|
|
;; Variable declared/used by `mpc-select-save'.
|
|
|
|
(when selection
|
|
|
|
(setq mpc--changed-selection t))
|
|
|
|
(unless nodeactivate
|
|
|
|
(setq selection nil)
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapc #'delete-overlay mpc-select)
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq mpc-select nil)
|
2014-08-12 16:16:00 +00:00
|
|
|
(mpc-tagbrowser-all-select))))
|
|
|
|
|
|
|
|
;; Don't bother splitting the "active" elements to the first part if
|
|
|
|
;; they're the same as the selection.
|
|
|
|
(when (equal (sort (copy-sequence active) #'string-lessp)
|
|
|
|
(sort (copy-sequence selection) #'string-lessp))
|
|
|
|
(setq active 'all)))
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
;; FIXME: This `mpc-sort' takes a lot of time. Maybe we should
|
|
|
|
;; be more clever and presume the buffer is mostly sorted already.
|
|
|
|
(mpc-sort (if (listp active) active))
|
|
|
|
(mpc-separator (if (listp active) active)))))
|
|
|
|
|
|
|
|
(defun mpc-selection-refresh ()
|
|
|
|
(let ((mpc--changed-selection t))
|
|
|
|
(while mpc--changed-selection
|
|
|
|
(setq mpc--changed-selection nil)
|
|
|
|
(dolist (buf (process-get (mpc-proc) 'buffers))
|
|
|
|
(setq buf (cdr buf))
|
|
|
|
(when (and (buffer-local-value 'mpc-tag buf)
|
|
|
|
(not (eq buf (current-buffer))))
|
|
|
|
(with-current-buffer buf (mpc-reorder)))))
|
|
|
|
;; FIXME: reorder the current buffer last and prevent deactivation,
|
|
|
|
;; since whatever selection we made here is the most recent one
|
|
|
|
;; and should hence take precedence.
|
|
|
|
(when mpc-tag (mpc-reorder 'nodeactivate))
|
|
|
|
;; FIXME: comment?
|
|
|
|
(if (and mpc--song-search mpc--changed-selection)
|
|
|
|
(progn
|
|
|
|
(setq mpc--song-search nil)
|
|
|
|
(mpc-selection-refresh))
|
|
|
|
(mpc-songs-refresh))))
|
|
|
|
|
|
|
|
;;; Hierarchical tagbrowser ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Todo:
|
|
|
|
;; - Add a button on each dir to open/close it (?)
|
2011-11-27 04:43:11 +00:00
|
|
|
;; - add the parent dir on the previous line, grayed-out, if it's not
|
2009-12-01 04:04:33 +00:00
|
|
|
;; present (because we're in the non-selected part and the parent is
|
|
|
|
;; in the selected part).
|
|
|
|
|
2022-07-17 10:56:38 +00:00
|
|
|
(defvar-keymap mpc-tagbrowser-dir-mode-map
|
|
|
|
:parent mpc-tagbrowser-mode-map
|
|
|
|
"M-RET" #'mpc-tagbrowser-dir-toggle)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;; (defvar mpc-tagbrowser-dir-keywords
|
|
|
|
;; '(mpc-tagbrowser-dir-hide-prefix))
|
|
|
|
|
|
|
|
(define-derived-mode mpc-tagbrowser-dir-mode mpc-tagbrowser-mode '("MPC-" mpc-tag-name)
|
2013-03-29 14:23:24 +00:00
|
|
|
;; (setq-local font-lock-defaults
|
2009-12-01 04:04:33 +00:00
|
|
|
;; '(mpc-tagbrowser-dir-keywords t))
|
|
|
|
)
|
|
|
|
|
|
|
|
;; (defun mpc-tagbrowser-dir-hide-prefix (limit)
|
|
|
|
;; (while
|
|
|
|
;; (let ((prev (buffer-substring (line-beginning-position 0)
|
|
|
|
;; (line-end-position 0))))
|
|
|
|
;; (
|
|
|
|
|
|
|
|
(defun mpc-tagbrowser-dir-toggle (event)
|
|
|
|
"Open or close the element at point."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(mpc-event-set-point event)
|
|
|
|
(let ((name (buffer-substring (line-beginning-position)
|
|
|
|
(line-end-position)))
|
2013-04-10 13:17:27 +00:00
|
|
|
(prop (intern mpc-tag))
|
|
|
|
(proc (mpc-proc)))
|
|
|
|
(if (not (member name (process-get proc prop)))
|
|
|
|
(process-put proc prop
|
|
|
|
(cons name (process-get proc prop)))
|
|
|
|
(let ((new (delete name (process-get proc prop))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq name (concat name "/"))
|
2013-04-10 13:17:27 +00:00
|
|
|
(process-put proc prop
|
2009-12-01 04:04:33 +00:00
|
|
|
(delq nil
|
|
|
|
(mapcar (lambda (x)
|
2012-04-16 23:57:09 +00:00
|
|
|
(if (string-prefix-p name x)
|
2009-12-01 04:04:33 +00:00
|
|
|
nil x))
|
|
|
|
new)))))
|
|
|
|
(mpc-tagbrowser-refresh)))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
;;; Playlist management ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2013-03-29 14:23:24 +00:00
|
|
|
(defvar-local mpc-songs-playlist nil
|
2009-12-01 04:04:33 +00:00
|
|
|
"Name of the currently selected playlist, if any.
|
2009-12-02 02:08:21 +00:00
|
|
|
A value of t means the main playlist.")
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-playlist-create (name)
|
|
|
|
"Save current playlist under name NAME."
|
|
|
|
(interactive "sPlaylist name: ")
|
|
|
|
(mpc-proc-cmd (list "save" name))
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'Playlist)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf (mpc-tagbrowser-refresh)))))
|
|
|
|
|
|
|
|
(defun mpc-playlist-destroy (name)
|
|
|
|
"Delete playlist named NAME."
|
|
|
|
(interactive
|
|
|
|
(list (completing-read "Delete playlist: " (mpc-cmd-list 'Playlist)
|
|
|
|
nil 'require-match)))
|
|
|
|
(mpc-proc-cmd (list "rm" name))
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'Playlist)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf (mpc-tagbrowser-refresh)))))
|
|
|
|
|
|
|
|
(defun mpc-playlist-rename (oldname newname)
|
|
|
|
"Rename playlist OLDNAME to NEWNAME."
|
|
|
|
(interactive
|
|
|
|
(let* ((oldname (if (and (eq mpc-tag 'Playlist) (null current-prefix-arg))
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
(line-end-position))
|
|
|
|
(completing-read "Rename playlist: "
|
|
|
|
(mpc-cmd-list 'Playlist)
|
|
|
|
nil 'require-match)))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 15:41:44 +00:00
|
|
|
(newname (read-string (format-message "Rename `%s' to: " oldname))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (zerop (length newname))
|
|
|
|
(error "Aborted")
|
|
|
|
(list oldname newname))))
|
|
|
|
(mpc-proc-cmd (list "rename" oldname newname))
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'Playlist)))
|
|
|
|
(if (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf (mpc-tagbrowser-refresh)))))
|
|
|
|
|
|
|
|
(defun mpc-playlist ()
|
|
|
|
"Show the current playlist."
|
|
|
|
(interactive)
|
|
|
|
(mpc-constraints-push 'noerror)
|
|
|
|
(mpc-constraints-restore '()))
|
|
|
|
|
|
|
|
(defun mpc-playlist-add ()
|
|
|
|
"Add the selection to the playlist."
|
|
|
|
(interactive)
|
|
|
|
(let ((songs (mapcar #'car (mpc-songs-selection))))
|
|
|
|
(mpc-cmd-add songs)
|
|
|
|
(message "Appended %d songs" (length songs))
|
|
|
|
;; Return the songs added. Used in `mpc-play'.
|
|
|
|
songs))
|
|
|
|
|
|
|
|
(defun mpc-playlist-delete ()
|
|
|
|
"Remove the selected songs from the playlist."
|
|
|
|
(interactive)
|
|
|
|
(unless mpc-songs-playlist
|
2010-01-02 01:05:44 +00:00
|
|
|
(error "The selected songs aren't part of a playlist"))
|
2009-12-01 04:04:33 +00:00
|
|
|
(let ((song-poss (mapcar #'cdr (mpc-songs-selection))))
|
|
|
|
(mpc-cmd-delete song-poss mpc-songs-playlist)
|
|
|
|
(mpc-songs-refresh)
|
|
|
|
(message "Deleted %d songs" (length song-poss))))
|
|
|
|
|
|
|
|
;;; Volume management ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2022-07-17 10:56:38 +00:00
|
|
|
(defvar-keymap mpc-volume-map
|
|
|
|
;; Bind the up-events rather than the down-event, so the
|
|
|
|
;; `message' isn't canceled by the subsequent up-event binding.
|
|
|
|
"<down-mouse-1>" #'ignore
|
|
|
|
"<mouse-1>" #'mpc-volume-mouse-set
|
|
|
|
"<header-line> <mouse-1>" #'mpc-volume-mouse-set
|
|
|
|
"<header-line> <down-mouse-1>" #'ignore
|
|
|
|
"<mode-line> <mouse-1>" #'mpc-volume-mouse-set
|
|
|
|
"<mode-line> <down-mouse-1>" #'ignore)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defvar mpc-volume nil) (put 'mpc-volume 'risky-local-variable t)
|
|
|
|
|
|
|
|
(defun mpc-volume-refresh ()
|
|
|
|
;; Maintain the volume.
|
|
|
|
(setq mpc-volume
|
|
|
|
(mpc-volume-widget
|
2014-09-22 13:42:57 +00:00
|
|
|
(string-to-number (cdr (assq 'volume mpc-status)))))
|
|
|
|
(let ((status-buf (mpc-proc-buffer (mpc-proc) 'status)))
|
2015-10-14 12:52:44 +00:00
|
|
|
(when (buffer-live-p status-buf)
|
|
|
|
(with-current-buffer status-buf (force-mode-line-update)))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
2021-09-29 16:22:43 +00:00
|
|
|
(defvar mpc-volume-step 5
|
|
|
|
"Change volume in increments of this integer.")
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-volume-mouse-set (&optional event)
|
|
|
|
"Change volume setting."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(let* ((posn (event-start event))
|
|
|
|
(diff
|
|
|
|
(if (memq (if (stringp (car-safe (posn-object posn)))
|
|
|
|
(aref (car (posn-object posn)) (cdr (posn-object posn)))
|
|
|
|
(with-current-buffer (window-buffer (posn-window posn))
|
|
|
|
(char-after (posn-point posn))))
|
|
|
|
'(?◁ ?<))
|
|
|
|
(- mpc-volume-step) mpc-volume-step))
|
2014-05-01 01:08:08 +00:00
|
|
|
(curvol (string-to-number (cdr (assq 'volume mpc-status))))
|
2021-09-29 16:22:43 +00:00
|
|
|
(newvol (max 0 (min 100 (+ (- curvol (mod curvol diff)) diff)))))
|
2014-05-01 01:08:08 +00:00
|
|
|
(if (= newvol curvol)
|
|
|
|
(progn
|
|
|
|
(message "MPD volume already at %s%%" newvol)
|
|
|
|
(ding))
|
2021-04-24 19:57:22 +00:00
|
|
|
(mpc-proc-cmd (list "setvol" newvol) #'mpc-status-refresh)
|
2014-05-01 01:08:08 +00:00
|
|
|
(message "Set MPD volume to %s%%" newvol))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-volume-widget (vol &optional size)
|
|
|
|
(unless size (setq size 12.5))
|
|
|
|
(let ((scaledvol (* (/ vol 100.0) size)))
|
|
|
|
;; (message "Volume sizes: %s - %s" (/ vol fact) (/ (- 100 vol) fact))
|
|
|
|
(list (propertize "<" ;; "◁"
|
|
|
|
;; 'face 'default
|
|
|
|
'keymap mpc-volume-map
|
|
|
|
'face '(:box (:line-width -2 :style pressed-button))
|
|
|
|
'mouse-face '(:box (:line-width -2 :style released-button)))
|
|
|
|
" "
|
|
|
|
(propertize "a"
|
|
|
|
'display (list 'space :width scaledvol)
|
|
|
|
'face '(:inverse-video t
|
|
|
|
:box (:line-width -2 :style released-button)))
|
|
|
|
(propertize "a"
|
|
|
|
'display (list 'space :width (- size scaledvol))
|
|
|
|
'face '(:box (:line-width -2 :style released-button)))
|
|
|
|
" "
|
|
|
|
(propertize ">" ;; "▷"
|
|
|
|
;; 'face 'default
|
|
|
|
'keymap mpc-volume-map
|
|
|
|
'face '(:box (:line-width -2 :style pressed-button))
|
|
|
|
'mouse-face '(:box (:line-width -2 :style released-button))))))
|
|
|
|
|
|
|
|
;;; MPC songs mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defvar mpc-current-song nil) (put 'mpc-current-song 'risky-local-variable t)
|
|
|
|
(defvar mpc-current-updating nil) (put 'mpc-current-updating 'risky-local-variable t)
|
|
|
|
(defvar mpc-songs-format-description nil) (put 'mpc-songs-format-description 'risky-local-variable t)
|
|
|
|
|
|
|
|
(defvar mpc-previous-window-config nil)
|
|
|
|
|
2022-07-17 10:56:38 +00:00
|
|
|
(defvar-keymap mpc-songs-mode-map
|
|
|
|
"<remap> <mpc-select>" #'mpc-songs-jump-to)
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defvar mpc-songpointer-set-visible nil)
|
|
|
|
|
|
|
|
(defvar mpc-songs-hashcons (make-hash-table :test 'equal :weakness t)
|
|
|
|
"Make song file name objects unique via hash consing.
|
|
|
|
This is used so that they can be compared with `eq', which is needed for
|
|
|
|
`text-property-any'.")
|
|
|
|
(defun mpc-songs-hashcons (name)
|
|
|
|
(or (gethash name mpc-songs-hashcons) (puthash name name mpc-songs-hashcons)))
|
2014-05-12 13:25:53 +00:00
|
|
|
(defcustom mpc-songs-format "%2{Disc--}%3{Track} %-5{Time} %25{Title} %20{Album} %20{Artist} %5{Date}"
|
2009-12-01 04:04:33 +00:00
|
|
|
"Format used to display each song in the list of songs."
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defvar mpc-songs-totaltime)
|
|
|
|
|
|
|
|
(defun mpc-songs-refresh ()
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'songs)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(let ((constraints (mpc-constraints-get-current (current-buffer)))
|
|
|
|
(dontsort nil)
|
|
|
|
(inhibit-read-only t)
|
|
|
|
(totaltime 0)
|
|
|
|
(curline (cons (count-lines (point-min)
|
|
|
|
(line-beginning-position))
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
(line-end-position))))
|
|
|
|
active)
|
|
|
|
(setq mpc-songs-playlist nil)
|
|
|
|
(if (null constraints)
|
|
|
|
;; When there are no constraints, rather than show the list of
|
|
|
|
;; all songs (which could take a while to download and
|
|
|
|
;; format), we show the current playlist.
|
|
|
|
;; FIXME: it would be good to be able to show the complete
|
|
|
|
;; list, but that would probably require us to format it
|
|
|
|
;; on-the-fly to make it bearable.
|
|
|
|
(setq dontsort t
|
|
|
|
mpc-songs-playlist t
|
|
|
|
active (mpc-proc-buf-to-alists
|
|
|
|
(mpc-proc-cmd "playlistinfo")))
|
|
|
|
(dolist (cst constraints)
|
|
|
|
(if (and (eq (car cst) 'Playlist)
|
|
|
|
(= 1 (length (cdr cst))))
|
|
|
|
(setq mpc-songs-playlist (cadr cst)))
|
|
|
|
;; We don't do anything really special here for playlists,
|
|
|
|
;; because it's unclear what's a correct "union" of playlists.
|
2021-04-24 19:57:22 +00:00
|
|
|
(let ((vals (apply #'mpc-union
|
2009-12-01 04:04:33 +00:00
|
|
|
(mapcar (lambda (val)
|
|
|
|
(mpc-cmd-find (car cst) val))
|
|
|
|
(cdr cst)))))
|
2010-03-25 00:06:08 +00:00
|
|
|
(setq active (cond
|
|
|
|
((null active)
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (eq (car cst) 'Playlist)
|
|
|
|
(setq dontsort t))
|
|
|
|
vals)
|
2010-03-25 00:06:08 +00:00
|
|
|
((or dontsort
|
2009-12-01 04:04:33 +00:00
|
|
|
;; Try to preserve ordering and
|
|
|
|
;; repetitions from playlists.
|
|
|
|
(not (eq (car cst) 'Playlist)))
|
|
|
|
(mpc-intersection active vals
|
2010-03-25 00:06:08 +00:00
|
|
|
(lambda (x) (assq 'file x))))
|
|
|
|
(t
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq dontsort t)
|
|
|
|
(mpc-intersection vals active
|
2010-03-25 00:06:08 +00:00
|
|
|
(lambda (x)
|
|
|
|
(assq 'file x)))))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-select-save
|
|
|
|
(erase-buffer)
|
|
|
|
;; Sorting songs is surprisingly difficult: when comparing two
|
|
|
|
;; songs with the same album name but different artist name, you
|
|
|
|
;; have to know whether these are two different albums (with the
|
|
|
|
;; same name) or a single album (typically a compilation).
|
|
|
|
;; I punt on it and just use file-name sorting, which does the
|
|
|
|
;; right thing if your library is properly arranged.
|
|
|
|
(dolist (song (if dontsort active
|
2015-10-13 13:48:16 +00:00
|
|
|
(sort (copy-sequence active)
|
2009-12-01 04:04:33 +00:00
|
|
|
(lambda (song1 song2)
|
|
|
|
(let ((cmp (mpc-compare-strings
|
|
|
|
(cdr (assq 'file song1))
|
|
|
|
(cdr (assq 'file song2)))))
|
|
|
|
(and (integerp cmp) (< cmp 0)))))))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf totaltime (string-to-number (or (cdr (assq 'Time song)) "0")))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-format mpc-songs-format song)
|
|
|
|
(delete-char (- (skip-chars-backward " "))) ;Remove trailing space.
|
|
|
|
(insert "\n")
|
|
|
|
(put-text-property
|
|
|
|
(line-beginning-position 0) (line-beginning-position)
|
|
|
|
'mpc-file (mpc-songs-hashcons (cdr (assq 'file song))))
|
|
|
|
(let ((pos (assq 'Pos song)))
|
|
|
|
(if pos
|
|
|
|
(put-text-property
|
|
|
|
(line-beginning-position 0) (line-beginning-position)
|
|
|
|
'mpc-file-pos (string-to-number (cdr pos)))))
|
|
|
|
))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (car curline))
|
2010-03-25 00:06:08 +00:00
|
|
|
(if (or (search-forward (cdr curline) nil t)
|
2009-12-01 04:04:33 +00:00
|
|
|
(search-backward (cdr curline) nil t))
|
2010-03-25 00:06:08 +00:00
|
|
|
(beginning-of-line)
|
|
|
|
(goto-char (point-min)))
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local mpc-songs-totaltime
|
|
|
|
(unless (zerop totaltime)
|
|
|
|
(list " " (mpc-secs-to-time totaltime))))
|
2009-12-01 04:04:33 +00:00
|
|
|
))))
|
|
|
|
(let ((mpc-songpointer-set-visible t))
|
|
|
|
(mpc-songpointer-refresh)))
|
|
|
|
|
|
|
|
(defun mpc-songs-search (string)
|
|
|
|
"Filter songs to those who include STRING in their metadata."
|
|
|
|
(interactive "sSearch for: ")
|
|
|
|
(setq mpc--song-search
|
|
|
|
(if (zerop (length string)) nil string))
|
|
|
|
(let ((mpc--changed-selection t))
|
|
|
|
(while mpc--changed-selection
|
|
|
|
(setq mpc--changed-selection nil)
|
|
|
|
(dolist (buf (process-get (mpc-proc) 'buffers))
|
|
|
|
(setq buf (cdr buf))
|
|
|
|
(when (buffer-local-value 'mpc-tag buf)
|
|
|
|
(with-current-buffer buf (mpc-reorder))))
|
|
|
|
(mpc-songs-refresh))))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-songs-kill-search ()
|
|
|
|
"Turn off the current search restriction."
|
|
|
|
(interactive)
|
|
|
|
(mpc-songs-search nil))
|
|
|
|
|
|
|
|
(defun mpc-songs-selection ()
|
|
|
|
"Return the list of songs currently selected."
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'songs)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(save-excursion
|
|
|
|
(let ((files ()))
|
|
|
|
(if mpc-select
|
|
|
|
(dolist (ol mpc-select)
|
|
|
|
(push (cons
|
|
|
|
(get-text-property (overlay-start ol) 'mpc-file)
|
|
|
|
(get-text-property (overlay-start ol) 'mpc-file-pos))
|
|
|
|
files))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (not (eobp))
|
|
|
|
(push (cons
|
|
|
|
(get-text-property (point) 'mpc-file)
|
|
|
|
(get-text-property (point) 'mpc-file-pos))
|
|
|
|
files)
|
|
|
|
(forward-line 1)))
|
|
|
|
(nreverse files)))))))
|
|
|
|
|
|
|
|
(defun mpc-songs-jump-to (song-file &optional posn)
|
2009-12-02 02:08:21 +00:00
|
|
|
"Jump to song SONG-FILE; interactively, this is the song at point."
|
2009-12-01 04:04:33 +00:00
|
|
|
(interactive
|
|
|
|
(let* ((event last-nonmenu-event)
|
|
|
|
(posn (event-end event)))
|
|
|
|
(with-selected-window (posn-window posn)
|
|
|
|
(goto-char (posn-point posn))
|
|
|
|
(list (get-text-property (point) 'mpc-file)
|
|
|
|
posn))))
|
|
|
|
(let* ((plbuf (mpc-proc-cmd "playlist"))
|
2011-10-14 18:37:53 +00:00
|
|
|
(re (if song-file
|
2013-10-08 03:48:01 +00:00
|
|
|
;; Newer MPCs apparently include "file: " in the buffer.
|
|
|
|
(concat "^\\([0-9]+\\):\\(?:file: \\)?"
|
|
|
|
(regexp-quote song-file) "$")))
|
2009-12-01 04:04:33 +00:00
|
|
|
(sn (with-current-buffer plbuf
|
|
|
|
(goto-char (point-min))
|
2011-10-14 18:37:53 +00:00
|
|
|
(when (and re (re-search-forward re nil t))
|
2009-12-01 04:04:33 +00:00
|
|
|
(match-string 1)))))
|
|
|
|
(cond
|
2011-10-14 18:37:53 +00:00
|
|
|
((null re) (posn-set-point posn))
|
2014-09-22 13:42:57 +00:00
|
|
|
((null sn) (user-error "This song is not in the playlist"))
|
2009-12-01 04:04:33 +00:00
|
|
|
((null (with-current-buffer plbuf (re-search-forward re nil t)))
|
|
|
|
;; song-file only appears once in the playlist: no ambiguity,
|
|
|
|
;; we're good to go!
|
2020-10-20 11:20:48 +00:00
|
|
|
(mpc-cmd-play sn))
|
2009-12-01 04:04:33 +00:00
|
|
|
(t
|
|
|
|
;; The song appears multiple times in the playlist. If the current
|
|
|
|
;; buffer holds not only the destination song but also the current
|
|
|
|
;; song, then we will move in the playlist to the same relative
|
|
|
|
;; position as in the buffer. Otherwise, we will simply choose the
|
|
|
|
;; song occurrence closest to the current song.
|
|
|
|
(with-selected-window (posn-window posn)
|
|
|
|
(let* ((cur (and (markerp overlay-arrow-position)
|
|
|
|
(marker-position overlay-arrow-position)))
|
|
|
|
(dest (save-excursion
|
|
|
|
(goto-char (posn-point posn))
|
|
|
|
(line-beginning-position)))
|
|
|
|
(lines (when cur (* (if (< cur dest) 1 -1)
|
|
|
|
(count-lines cur dest)))))
|
|
|
|
(with-current-buffer plbuf
|
|
|
|
(goto-char (point-min))
|
|
|
|
;; Start the search from the current song.
|
|
|
|
(forward-line (string-to-number
|
|
|
|
(or (cdr (assq 'song mpc-status)) "0")))
|
|
|
|
;; If the current song is also displayed in the buffer,
|
|
|
|
;; then try to move to the same relative position.
|
|
|
|
(if lines (forward-line lines))
|
|
|
|
;; Now search the closest occurrence.
|
|
|
|
(let* ((next (save-excursion
|
|
|
|
(when (re-search-forward re nil t)
|
|
|
|
(cons (point) (match-string 1)))))
|
|
|
|
(prev (save-excursion
|
|
|
|
(when (re-search-backward re nil t)
|
|
|
|
(cons (point) (match-string 1)))))
|
|
|
|
(sn (cdr (if (and next prev)
|
|
|
|
(if (< (- (car next) (point))
|
|
|
|
(- (point) (car prev)))
|
|
|
|
next prev)
|
|
|
|
(or next prev)))))
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-assert sn)
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd (concat "play " sn))))))))))
|
|
|
|
|
|
|
|
(define-derived-mode mpc-songs-mode mpc-mode "MPC-song"
|
|
|
|
(setq mpc-songs-format-description
|
|
|
|
(with-temp-buffer (mpc-format mpc-songs-format 'self) (buffer-string)))
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local header-line-format
|
|
|
|
;; '("MPC " mpc-volume " " mpc-current-song)
|
|
|
|
(list (propertize " " 'display '(space :align-to 0))
|
|
|
|
;; 'mpc-songs-format-description
|
|
|
|
'(:eval
|
|
|
|
(let ((hscroll (window-hscroll)))
|
|
|
|
(with-temp-buffer
|
|
|
|
(mpc-format mpc-songs-format 'self hscroll)
|
|
|
|
;; That would be simpler than the hscroll handling in
|
|
|
|
;; mpc-format, but currently move-to-column does not
|
|
|
|
;; recognize :space display properties.
|
|
|
|
;; (move-to-column hscroll)
|
|
|
|
;; (delete-region (point-min) (point))
|
|
|
|
(buffer-string))))))
|
|
|
|
(setq-local
|
|
|
|
mode-line-format
|
|
|
|
'("%e" mode-line-frame-identification mode-line-buffer-identification
|
|
|
|
#(" " 0 3
|
|
|
|
(help-echo "mouse-1: Select (drag to resize)\nmouse-2: Make current window occupy the whole frame\nmouse-3: Remove current window from display"))
|
|
|
|
mode-line-position
|
|
|
|
#(" " 0 2
|
|
|
|
(help-echo "mouse-1: Select (drag to resize)\nmouse-2: Make current window occupy the whole frame\nmouse-3: Remove current window from display"))
|
|
|
|
mpc-songs-totaltime
|
|
|
|
mpc-current-updating
|
|
|
|
#(" " 0 2
|
|
|
|
(help-echo "mouse-1: Select (drag to resize)\nmouse-2: Make current window occupy the whole frame\nmouse-3: Remove current window from display"))
|
|
|
|
(mpc--song-search
|
|
|
|
(:propertize
|
|
|
|
("Search=\"" mpc--song-search "\"")
|
|
|
|
help-echo "mouse-2: kill this search"
|
|
|
|
follow-link t
|
|
|
|
mouse-face mode-line-highlight
|
|
|
|
keymap (keymap (mode-line keymap
|
|
|
|
(mouse-2 . mpc-songs-kill-search))))
|
|
|
|
(:propertize "NoSearch"
|
|
|
|
help-echo "mouse-2: set a search restriction"
|
|
|
|
follow-link t
|
|
|
|
mouse-face mode-line-highlight
|
|
|
|
keymap (keymap (mode-line keymap (mouse-2 . mpc-songs-search)))))))
|
|
|
|
|
|
|
|
;; (setq-local mode-line-process
|
2009-12-01 04:04:33 +00:00
|
|
|
;; '("" ;; mpc-volume " "
|
|
|
|
;; mpc-songs-totaltime
|
|
|
|
;; mpc-current-updating))
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun mpc-songpointer-set (pos)
|
|
|
|
(let* ((win (get-buffer-window (current-buffer) t))
|
|
|
|
(visible (when win
|
|
|
|
(or mpc-songpointer-set-visible
|
|
|
|
(and (markerp overlay-arrow-position)
|
|
|
|
(eq (marker-buffer overlay-arrow-position)
|
|
|
|
(current-buffer))
|
|
|
|
(<= (window-start win) overlay-arrow-position)
|
|
|
|
(< overlay-arrow-position (window-end win)))))))
|
|
|
|
(unless (local-variable-p 'overlay-arrow-position)
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local overlay-arrow-position (make-marker)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(move-marker overlay-arrow-position pos)
|
|
|
|
;; If the arrow was visible, try to keep it that way.
|
|
|
|
(if (and visible pos
|
|
|
|
(or (> (window-start win) pos) (>= pos (window-end win t))))
|
|
|
|
(set-window-point win pos))))
|
|
|
|
|
|
|
|
(defun mpc-songpointer-refresh ()
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'songs)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(let* ((pos (text-property-any
|
|
|
|
(point-min) (point-max)
|
|
|
|
'mpc-file (mpc-songs-hashcons
|
|
|
|
(cdr (assq 'file mpc-status)))))
|
|
|
|
(other (when pos
|
|
|
|
(save-excursion
|
|
|
|
(goto-char pos)
|
|
|
|
(text-property-any
|
|
|
|
(line-beginning-position 2) (point-max)
|
|
|
|
'mpc-file (mpc-songs-hashcons
|
|
|
|
(cdr (assq 'file mpc-status))))))))
|
|
|
|
(if other
|
|
|
|
;; The song appears multiple times in the buffer.
|
|
|
|
;; We need to be careful to choose the right occurrence.
|
|
|
|
(mpc-proc-cmd "playlist" 'mpc-songpointer-refresh-hairy)
|
|
|
|
(mpc-songpointer-set pos)))))))
|
|
|
|
|
|
|
|
(defun mpc-songpointer-context (size plbuf)
|
|
|
|
(with-current-buffer plbuf
|
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (string-to-number (or (cdr (assq 'song mpc-status)) "0")))
|
|
|
|
(let ((context-before '())
|
|
|
|
(context-after '()))
|
|
|
|
(save-excursion
|
2011-06-02 11:24:12 +00:00
|
|
|
(dotimes (_i size)
|
2009-12-01 04:04:33 +00:00
|
|
|
(when (re-search-backward "^[0-9]+:\\(.*\\)" nil t)
|
|
|
|
(push (mpc-songs-hashcons (match-string 1)) context-before))))
|
|
|
|
;; Skip the actual current song.
|
|
|
|
(forward-line 1)
|
2011-06-02 11:24:12 +00:00
|
|
|
(dotimes (_i size)
|
2009-12-01 04:04:33 +00:00
|
|
|
(when (re-search-forward "^[0-9]+:\\(.*\\)" nil t)
|
|
|
|
(push (mpc-songs-hashcons (match-string 1)) context-after)))
|
|
|
|
;; If there isn't `size' context, then return nil.
|
|
|
|
(unless (and (< (length context-before) size)
|
|
|
|
(< (length context-after) size))
|
|
|
|
(cons (nreverse context-before) (nreverse context-after))))))
|
|
|
|
|
|
|
|
(defun mpc-songpointer-score (context pos)
|
|
|
|
(let ((count 0))
|
|
|
|
(goto-char pos)
|
|
|
|
(dolist (song (car context))
|
|
|
|
(and (zerop (forward-line -1))
|
|
|
|
(eq (get-text-property (point) 'mpc-file) song)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf count)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(goto-char pos)
|
|
|
|
(dolist (song (cdr context))
|
|
|
|
(and (zerop (forward-line 1))
|
|
|
|
(eq (get-text-property (point) 'mpc-file) song)
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf count)))
|
2009-12-01 04:04:33 +00:00
|
|
|
count))
|
|
|
|
|
|
|
|
(defun mpc-songpointer-refresh-hairy ()
|
|
|
|
;; Based on the complete playlist, we should figure out where in the
|
|
|
|
;; song buffer is the currently playing song.
|
|
|
|
(let ((plbuf (current-buffer))
|
|
|
|
(buf (mpc-proc-buffer (mpc-proc) 'songs)))
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(let* ((context-size 0)
|
|
|
|
(context '(() . ()))
|
|
|
|
(pos (text-property-any
|
|
|
|
(point-min) (point-max)
|
|
|
|
'mpc-file (mpc-songs-hashcons
|
|
|
|
(cdr (assq 'file mpc-status)))))
|
|
|
|
(score 0)
|
|
|
|
(other pos))
|
|
|
|
(while
|
|
|
|
(setq other
|
|
|
|
(save-excursion
|
|
|
|
(goto-char other)
|
|
|
|
(text-property-any
|
|
|
|
(line-beginning-position 2) (point-max)
|
|
|
|
'mpc-file (mpc-songs-hashcons
|
|
|
|
(cdr (assq 'file mpc-status))))))
|
|
|
|
;; There is an `other' contestant.
|
|
|
|
(let ((other-score (mpc-songpointer-score context other)))
|
|
|
|
(cond
|
|
|
|
;; `other' is worse: try the next one.
|
|
|
|
((< other-score score) nil)
|
|
|
|
;; `other' is better: remember it and then search further.
|
|
|
|
((> other-score score)
|
|
|
|
(setq pos other)
|
|
|
|
(setq score other-score))
|
|
|
|
;; Both are equal and increasing the context size won't help.
|
|
|
|
;; Arbitrarily choose one of the two and keep looking
|
|
|
|
;; for a better match.
|
|
|
|
((< score context-size) nil)
|
|
|
|
(t
|
|
|
|
;; Score is equal and increasing context might help: try it.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-incf context-size)
|
2009-12-01 04:04:33 +00:00
|
|
|
(let ((new-context
|
|
|
|
(mpc-songpointer-context context-size plbuf)))
|
|
|
|
(if (null new-context)
|
|
|
|
;; There isn't more context: choose one arbitrarily
|
|
|
|
;; and keep looking for a better match elsewhere.
|
Reduce use of (require 'cl).
* admin/bzrmerge.el: Use cl-lib.
* leim/quail/hangul.el: Don't require CL.
* leim/quail/ipa.el: Use cl-lib.
* vc/smerge-mode.el, vc/pcvs.el, vc/pcvs-util.el, vc/pcvs-info.el:
* vc/diff-mode.el, vc/cvs-status.el, uniquify.el, scroll-bar.el:
* register.el, progmodes/sh-script.el, net/gnutls.el, net/dbus.el:
* msb.el, mpc.el, minibuffer.el, international/ucs-normalize.el:
* international/quail.el, info-xref.el, imenu.el, image-mode.el:
* font-lock.el, filesets.el, edmacro.el, doc-view.el, bookmark.el:
* battery.el, avoid.el, abbrev.el: Use cl-lib.
* vc/pcvs-parse.el, vc/pcvs-defs.el, vc/log-view.el, vc/log-edit.el:
* vc/diff.el, simple.el, pcomplete.el, lpr.el, comint.el, loadhist.el:
* jit-lock.el, international/iso-ascii.el, info.el, frame.el, bs.el:
* emulation/crisp.el, electric.el, dired.el, cus-dep.el, composite.el:
* calculator.el, autorevert.el, apropos.el: Don't require CL.
* emacs-bytecomp.el (byte-recompile-directory, display-call-tree)
(byte-compile-unfold-bcf, byte-compile-check-variable):
* emacs-byte-opt.el (byte-compile-trueconstp)
(byte-compile-nilconstp):
* emacs-autoload.el (make-autoload): Use pcase.
* face-remap.el (text-scale-adjust): Simplify pcase patterns.
2012-07-10 11:51:54 +00:00
|
|
|
(cl-decf context-size)
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq context new-context)
|
|
|
|
(setq score (mpc-songpointer-score context pos))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char other)
|
|
|
|
;; Go back one line so we find `other' again.
|
|
|
|
(setq other (line-beginning-position 0)))))))))
|
|
|
|
(mpc-songpointer-set pos))))))
|
|
|
|
|
|
|
|
(defun mpc-current-refresh ()
|
|
|
|
;; Maintain the current data.
|
|
|
|
(mpc-status-buffer-refresh)
|
|
|
|
(setq mpc-current-updating
|
|
|
|
(if (assq 'updating_db mpc-status) " Updating-DB"))
|
|
|
|
(ignore-errors
|
|
|
|
(setq mpc-current-song
|
|
|
|
(when (assq 'file mpc-status)
|
|
|
|
(concat " "
|
|
|
|
(mpc-secs-to-time (cdr (assq 'time mpc-status)))
|
|
|
|
" "
|
|
|
|
(cdr (assq 'Title mpc-status))
|
|
|
|
" ("
|
|
|
|
(cdr (assq 'Artist mpc-status))
|
|
|
|
" / "
|
|
|
|
(cdr (assq 'Album mpc-status))
|
|
|
|
")"))))
|
|
|
|
(force-mode-line-update t))
|
|
|
|
|
|
|
|
(defun mpc-songs-buf ()
|
|
|
|
(let ((buf (mpc-proc-buffer (mpc-proc) 'songs)))
|
|
|
|
(if (buffer-live-p buf) buf
|
|
|
|
(with-current-buffer (setq buf (get-buffer-create "*MPC-Songs*"))
|
|
|
|
(mpc-proc-buffer (mpc-proc) 'songs buf)
|
|
|
|
(mpc-songs-mode)
|
|
|
|
buf))))
|
|
|
|
|
|
|
|
(defun mpc-update ()
|
|
|
|
"Tell MPD to refresh its database."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-update))
|
|
|
|
|
|
|
|
(defun mpc-quit ()
|
|
|
|
"Quit Music Player Daemon."
|
|
|
|
(interactive)
|
|
|
|
(let* ((proc mpc-proc)
|
2021-04-24 19:57:22 +00:00
|
|
|
(bufs (mapcar #'cdr (if proc (process-get proc 'buffers))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(wins (mapcar (lambda (buf) (get-buffer-window buf 0)) bufs))
|
|
|
|
(song-buf (mpc-songs-buf))
|
|
|
|
frames)
|
|
|
|
;; Collect all the frames where MPC buffers appear.
|
|
|
|
(dolist (win wins)
|
|
|
|
(when (and win (not (memq (window-frame win) frames)))
|
|
|
|
(push (window-frame win) frames)))
|
|
|
|
(if (and frames song-buf
|
|
|
|
(with-current-buffer song-buf mpc-previous-window-config))
|
|
|
|
(progn
|
|
|
|
(select-frame (car frames))
|
|
|
|
(set-window-configuration
|
|
|
|
(with-current-buffer song-buf mpc-previous-window-config)))
|
|
|
|
;; Now delete the ones that show nothing else than MPC buffers.
|
|
|
|
(dolist (frame frames)
|
|
|
|
(let ((delete t))
|
|
|
|
(dolist (win (window-list frame))
|
|
|
|
(unless (memq (window-buffer win) bufs) (setq delete nil)))
|
|
|
|
(if delete (ignore-errors (delete-frame frame))))))
|
|
|
|
;; Then kill the buffers.
|
2021-04-24 19:57:22 +00:00
|
|
|
(mapc #'kill-buffer bufs)
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-status-stop)
|
|
|
|
(if proc (delete-process proc))))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2015-10-16 13:56:05 +00:00
|
|
|
(defun mpc-toggle-consume ()
|
2015-10-15 16:32:59 +00:00
|
|
|
"Toggle consume mode: removing played songs from the playlist."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-consume
|
|
|
|
(if (string= "0" (cdr (assq 'consume (mpc-cmd-status)))) "1" "0")))
|
|
|
|
|
2015-10-16 13:56:05 +00:00
|
|
|
(defun mpc-toggle-repeat ()
|
2015-10-15 16:32:59 +00:00
|
|
|
"Toggle repeat mode."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-repeat
|
|
|
|
(if (string= "0" (cdr (assq 'repeat (mpc-cmd-status)))) "1" "0")))
|
|
|
|
|
2015-10-16 13:56:05 +00:00
|
|
|
(defun mpc-toggle-single ()
|
2015-10-15 16:32:59 +00:00
|
|
|
"Toggle single mode."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-single
|
|
|
|
(if (string= "0" (cdr (assq 'single (mpc-cmd-status)))) "1" "0")))
|
|
|
|
|
2015-10-16 13:56:05 +00:00
|
|
|
(defun mpc-toggle-shuffle ()
|
2015-10-15 16:32:59 +00:00
|
|
|
"Toggle shuffling of the playlist (random mode)."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-random
|
|
|
|
(if (string= "0" (cdr (assq 'random (mpc-cmd-status)))) "1" "0")))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-stop ()
|
|
|
|
"Stop playing the current queue of songs."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-stop)
|
|
|
|
(mpc-cmd-clear)
|
2020-10-20 11:20:48 +00:00
|
|
|
(mpc-songs-refresh)
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-status-refresh))
|
|
|
|
|
|
|
|
(defun mpc-pause ()
|
|
|
|
"Pause playing."
|
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-pause "1"))
|
|
|
|
|
|
|
|
(defun mpc-resume ()
|
2009-12-02 02:08:21 +00:00
|
|
|
"Resume playing."
|
2009-12-01 04:04:33 +00:00
|
|
|
(interactive)
|
|
|
|
(mpc-cmd-pause "0"))
|
|
|
|
|
2017-09-24 12:17:34 +00:00
|
|
|
(defun mpc-read-seek (prompt)
|
|
|
|
"Read a seek time.
|
|
|
|
Returns a string suitable for MPD \"seekcur\" protocol command."
|
|
|
|
(let* ((str (read-from-minibuffer prompt nil nil nil nil nil t))
|
|
|
|
(seconds "\\(?1:[[:digit:]]+\\(?:\\.[[:digit:]]*\\)?\\)")
|
|
|
|
(minsec (concat "\\(?2:[[:digit:]]+\\):" seconds "?"))
|
|
|
|
(hrminsec (concat "\\(?3:[[:digit:]]+\\):\\(?:" minsec "?\\|:\\)"))
|
|
|
|
time sign)
|
|
|
|
(setq str (string-trim str))
|
|
|
|
(when (memq (string-to-char str) '(?+ ?-))
|
|
|
|
(setq sign (string (string-to-char str)))
|
|
|
|
(setq str (substring str 1)))
|
|
|
|
(setq time
|
|
|
|
;; `string-to-number' returns 0 on failure
|
|
|
|
(cond
|
|
|
|
((string-match (concat "^" hrminsec "$") str)
|
|
|
|
(+ (* 3600 (string-to-number (match-string 3 str)))
|
|
|
|
(* 60 (string-to-number (or (match-string 2 str) "")))
|
|
|
|
(string-to-number (or (match-string 1 str) ""))))
|
|
|
|
((string-match (concat "^" minsec "$") str)
|
|
|
|
(+ (* 60 (string-to-number (match-string 2 str)))
|
|
|
|
(string-to-number (match-string 1 str))))
|
|
|
|
((string-match (concat "^" seconds "$") str)
|
|
|
|
(string-to-number (match-string 1 str)))
|
|
|
|
(t (user-error "Invalid time"))))
|
|
|
|
(setq time (number-to-string time))
|
|
|
|
(if (null sign) time (concat sign time))))
|
|
|
|
|
2015-11-18 18:46:24 +00:00
|
|
|
(defun mpc-seek-current (pos)
|
|
|
|
"Seek within current track."
|
|
|
|
(interactive
|
2017-09-24 12:17:34 +00:00
|
|
|
(list (mpc-read-seek "Position to go ([+-][[H:]M:]seconds): ")))
|
2015-11-18 18:46:24 +00:00
|
|
|
(mpc-cmd-seekcur pos))
|
|
|
|
|
2015-10-14 02:49:58 +00:00
|
|
|
(defun mpc-toggle-play ()
|
2015-10-14 21:32:47 +00:00
|
|
|
"Toggle between play and pause.
|
2015-10-14 02:49:58 +00:00
|
|
|
If stopped, start playback."
|
|
|
|
(interactive)
|
|
|
|
(if (member (cdr (assq 'state (mpc-cmd-status))) '("stop"))
|
|
|
|
(mpc-cmd-play)
|
|
|
|
(if (member (cdr (assq 'state (mpc-cmd-status))) '("pause"))
|
|
|
|
(mpc-resume)
|
|
|
|
(mpc-pause))))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-play ()
|
|
|
|
"Start playing whatever is selected."
|
|
|
|
(interactive)
|
|
|
|
(if (member (cdr (assq 'state (mpc-cmd-status))) '("pause"))
|
|
|
|
(mpc-resume)
|
|
|
|
;; When playing the playlist ends, the playlist isn't cleared, but the
|
|
|
|
;; user probably doesn't want to re-listen to it before getting to
|
|
|
|
;; listen to what he just selected.
|
|
|
|
;; (if (member (cdr (assq 'state (mpc-cmd-status))) '("stop"))
|
|
|
|
;; (mpc-cmd-clear))
|
|
|
|
;; Actually, we don't use mpc-play to append to the playlist any more,
|
|
|
|
;; so we can just always empty the playlist.
|
|
|
|
(mpc-cmd-clear)
|
|
|
|
(if (mpc-playlist-add)
|
|
|
|
(if (member (cdr (assq 'state (mpc-cmd-status))) '("stop"))
|
|
|
|
(mpc-cmd-play))
|
2014-09-22 13:42:57 +00:00
|
|
|
(user-error "Don't know what to play"))))
|
2009-12-01 04:04:33 +00:00
|
|
|
|
|
|
|
(defun mpc-next ()
|
|
|
|
"Jump to the next song in the queue."
|
|
|
|
(interactive)
|
|
|
|
(mpc-proc-cmd "next")
|
|
|
|
(mpc-status-refresh))
|
|
|
|
|
|
|
|
(defun mpc-prev ()
|
|
|
|
"Jump to the beginning of the current song, or to the previous song."
|
|
|
|
(interactive)
|
|
|
|
(let ((time (cdr (assq 'time mpc-status))))
|
|
|
|
;; Here we rely on the fact that string-to-number silently ignores
|
|
|
|
;; everything after a non-digit char.
|
|
|
|
(cond
|
|
|
|
;; Go back to the beginning of current song.
|
|
|
|
((and time (> (string-to-number time) 0))
|
|
|
|
(mpc-proc-cmd (list "seekid" (cdr (assq 'songid mpc-status)) 0)))
|
|
|
|
;; We're at the beginning of the first song of the playlist.
|
|
|
|
;; Fetch the previous one from `mpc-queue-back'.
|
|
|
|
;; ((and (zerop (string-to-number (cdr (assq 'song mpc-status))))
|
|
|
|
;; mpc-queue-back)
|
|
|
|
;; ;; Because we use cmd-list rather than cmd-play, the queue is not
|
|
|
|
;; ;; automatically updated.
|
|
|
|
;; (let ((prev (pop mpc-queue-back)))
|
|
|
|
;; (push prev mpc-queue)
|
|
|
|
;; (mpc-proc-cmd
|
|
|
|
;; (mpc-proc-cmd-list
|
|
|
|
;; (list (list "add" prev)
|
|
|
|
;; (list "move" (cdr (assq 'playlistlength mpc-status)) "0")
|
|
|
|
;; "previous")))))
|
|
|
|
;; We're at the beginning of a song, but not the first one.
|
|
|
|
(t (mpc-proc-cmd "previous")))
|
|
|
|
(mpc-status-refresh)))
|
|
|
|
|
|
|
|
(defvar mpc-last-seek-time '(0 . 0))
|
|
|
|
|
|
|
|
(defun mpc--faster (event speedup step)
|
|
|
|
"Fast forward."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(let ((repeat-delay (/ (abs (float step)) speedup)))
|
|
|
|
(if (not (memq 'down (event-modifiers event)))
|
|
|
|
(let* ((currenttime (float-time))
|
|
|
|
(last-time (- currenttime (car mpc-last-seek-time))))
|
|
|
|
(if (< last-time (* 0.9 repeat-delay))
|
2011-11-14 20:23:26 +00:00
|
|
|
nil ;; Throttle
|
2009-12-01 04:04:33 +00:00
|
|
|
(let* ((status (if (< last-time 1.0)
|
|
|
|
mpc-status (mpc-cmd-status)))
|
|
|
|
(songid (cdr (assq 'songid status)))
|
|
|
|
(time (if songid
|
|
|
|
(if (< last-time 1.0)
|
|
|
|
(cdr mpc-last-seek-time)
|
|
|
|
(string-to-number
|
|
|
|
(cdr (assq 'time status)))))))
|
|
|
|
(setq mpc-last-seek-time
|
|
|
|
(cons currenttime (setq time (+ time step))))
|
|
|
|
(mpc-proc-cmd (list "seekid" songid time)
|
2021-04-24 19:57:22 +00:00
|
|
|
#'mpc-status-refresh))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(let ((status (mpc-cmd-status)))
|
2011-02-10 18:53:49 +00:00
|
|
|
(let* ((songid (cdr (assq 'songid status)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(time (if songid (string-to-number
|
|
|
|
(cdr (assq 'time status))))))
|
|
|
|
(let ((timer (run-with-timer
|
|
|
|
t repeat-delay
|
|
|
|
(lambda ()
|
|
|
|
(mpc-proc-cmd (list "seekid" songid
|
|
|
|
(setq time (+ time step)))
|
2021-04-24 19:57:22 +00:00
|
|
|
#'mpc-status-refresh)))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(while (mouse-movement-p
|
|
|
|
(event-basic-type (setq event (read-event)))))
|
|
|
|
(cancel-timer timer)))))))
|
|
|
|
|
|
|
|
(defvar mpc--faster-toggle-timer nil)
|
|
|
|
(defun mpc--faster-stop ()
|
|
|
|
(when mpc--faster-toggle-timer
|
|
|
|
(cancel-timer mpc--faster-toggle-timer)
|
|
|
|
(setq mpc--faster-toggle-timer nil)))
|
|
|
|
|
|
|
|
(defun mpc--faster-toggle-refresh ()
|
|
|
|
(if (equal (cdr (assq 'state mpc-status)) "stop")
|
|
|
|
(mpc--faster-stop)))
|
|
|
|
|
|
|
|
(defun mpc--songduration ()
|
|
|
|
(string-to-number
|
|
|
|
(let ((s (cdr (assq 'time mpc-status))))
|
|
|
|
(if (not (string-match ":" s))
|
|
|
|
(error "Unexpected time format %S" s)
|
|
|
|
(substring s (match-end 0))))))
|
|
|
|
|
|
|
|
(defvar mpc--faster-toggle-forward nil)
|
|
|
|
(defvar mpc--faster-acceleration 0.5)
|
|
|
|
(defun mpc--faster-toggle (speedup step)
|
|
|
|
(if mpc--faster-toggle-timer
|
|
|
|
(mpc--faster-stop)
|
|
|
|
(mpc-status-refresh) (mpc-proc-sync)
|
2011-02-10 18:53:49 +00:00
|
|
|
(let* (songid ;The ID of the currently ffwd/rewinding song.
|
|
|
|
songduration ;The duration of that song.
|
|
|
|
songtime ;The time of the song last time we ran.
|
2011-12-31 01:27:15 +00:00
|
|
|
oldtime ;The time of day last time we ran.
|
2011-02-10 18:53:49 +00:00
|
|
|
prevsongid) ;The song we're in the process leaving.
|
2009-12-01 04:04:33 +00:00
|
|
|
(let ((fun
|
|
|
|
(lambda ()
|
2011-03-01 05:03:24 +00:00
|
|
|
(let ((newsongid (cdr (assq 'songid mpc-status))))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (and (equal prevsongid newsongid)
|
|
|
|
(not (equal prevsongid songid)))
|
|
|
|
;; We left prevsongid and came back to it. Pretend it
|
|
|
|
;; didn't happen.
|
|
|
|
(setq newsongid songid))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(cond
|
|
|
|
((null newsongid) (mpc--faster-stop))
|
|
|
|
((not (equal songid newsongid))
|
|
|
|
;; We jumped to another song: reset.
|
|
|
|
(setq songid newsongid)
|
|
|
|
(setq songtime (string-to-number
|
|
|
|
(cdr (assq 'time mpc-status))))
|
|
|
|
(setq songduration (mpc--songduration))
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-23 02:32:31 +00:00
|
|
|
(setq oldtime (current-time)))
|
2009-12-01 04:04:33 +00:00
|
|
|
((and (>= songtime songduration) mpc--faster-toggle-forward)
|
|
|
|
;; Skip to the beginning of the next song.
|
|
|
|
(if (not (equal (cdr (assq 'state mpc-status)) "play"))
|
2021-04-24 19:57:22 +00:00
|
|
|
(mpc-proc-cmd "next" #'mpc-status-refresh)
|
2009-12-01 04:04:33 +00:00
|
|
|
;; If we're playing, this is done automatically, so we
|
|
|
|
;; don't need to do anything, or rather we *shouldn't*
|
|
|
|
;; do anything otherwise there's a race condition where
|
|
|
|
;; we could skip straight to the next next song.
|
|
|
|
nil))
|
|
|
|
((and (<= songtime 0) (not mpc--faster-toggle-forward))
|
|
|
|
;; Skip to the end of the previous song.
|
|
|
|
(setq prevsongid songid)
|
|
|
|
(mpc-proc-cmd "previous"
|
|
|
|
(lambda ()
|
|
|
|
(mpc-status-refresh
|
|
|
|
(lambda ()
|
|
|
|
(setq songid (cdr (assq 'songid mpc-status)))
|
|
|
|
(setq songtime (setq songduration (mpc--songduration)))
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-23 02:32:31 +00:00
|
|
|
(setq oldtime (current-time))
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-proc-cmd (list "seekid" songid songtime)))))))
|
|
|
|
(t
|
|
|
|
(setq speedup (+ speedup mpc--faster-acceleration))
|
|
|
|
(let ((newstep
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-23 02:32:31 +00:00
|
|
|
(truncate
|
|
|
|
(* speedup
|
|
|
|
(float-time (time-since oldtime))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (<= newstep 1) (setq newstep 1))
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-23 02:32:31 +00:00
|
|
|
(setq oldtime (time-add oldtime (/ newstep speedup)))
|
2009-12-01 04:04:33 +00:00
|
|
|
(if (not mpc--faster-toggle-forward)
|
|
|
|
(setq newstep (- newstep)))
|
|
|
|
(setq songtime (min songduration (+ songtime newstep)))
|
|
|
|
(unless (>= songtime songduration)
|
|
|
|
(condition-case nil
|
|
|
|
(mpc-proc-cmd
|
|
|
|
(list "seekid" songid songtime)
|
2021-04-24 19:57:22 +00:00
|
|
|
#'mpc-status-refresh)
|
2011-03-01 05:03:24 +00:00
|
|
|
(mpc-proc-error (mpc-status-refresh)))))))))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(setq mpc--faster-toggle-forward (> step 0))
|
|
|
|
(funcall fun) ;Initialize values.
|
|
|
|
(setq mpc--faster-toggle-timer
|
|
|
|
(run-with-timer t 0.3 fun))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defvar mpc-faster-speedup 8)
|
|
|
|
|
2011-03-11 20:04:22 +00:00
|
|
|
(defun mpc-ffwd (_event)
|
2009-12-01 04:04:33 +00:00
|
|
|
"Fast forward."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
;; (mpc--faster event 4.0 1)
|
|
|
|
(mpc--faster-toggle mpc-faster-speedup 1))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
2011-03-11 20:04:22 +00:00
|
|
|
(defun mpc-rewind (_event)
|
2009-12-01 04:04:33 +00:00
|
|
|
"Fast rewind."
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
;; (mpc--faster event 4.0 -1)
|
|
|
|
(mpc--faster-toggle mpc-faster-speedup -1))
|
2009-12-01 16:21:36 +00:00
|
|
|
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
(defun mpc-play-at-point (&optional event)
|
|
|
|
(interactive (list last-nonmenu-event))
|
|
|
|
(mpc-select event)
|
|
|
|
(mpc-play))
|
|
|
|
|
2021-09-29 23:17:24 +00:00
|
|
|
(defun mpc-goto-playing-song ()
|
|
|
|
"Move point to the currently playing song in the \"*Songs*\" buffer."
|
|
|
|
(interactive)
|
|
|
|
(let* ((buf (mpc-proc-buffer (mpc-proc) 'songs))
|
|
|
|
(win (get-buffer-window buf)))
|
|
|
|
(when (and (buffer-live-p buf) win)
|
|
|
|
(select-window win)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(when (and overlay-arrow-position
|
|
|
|
(eq (marker-buffer overlay-arrow-position) buf))
|
|
|
|
(goto-char (marker-position overlay-arrow-position)))))))
|
|
|
|
|
2009-12-01 04:04:33 +00:00
|
|
|
;; (defun mpc-play-tagval ()
|
|
|
|
;; "Play all the songs of the tag at point."
|
|
|
|
;; (interactive)
|
|
|
|
;; (let* ((val (buffer-substring (line-beginning-position) (line-end-position)))
|
|
|
|
;; (songs (mapcar 'cdar
|
|
|
|
;; (mpc-proc-buf-to-alists
|
|
|
|
;; (mpc-proc-cmd (list "find" mpc-tag val))))))
|
|
|
|
;; (mpc-cmd-add songs)
|
|
|
|
;; (if (member (cdr (assq 'state (mpc-cmd-status))) '("stop"))
|
|
|
|
;; (mpc-cmd-play))))
|
|
|
|
|
|
|
|
;;; Drag'n'drop support ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Todo:
|
|
|
|
;; the main thing to do here, is to provide visual feedback during the drag:
|
|
|
|
;; - change the mouse-cursor.
|
|
|
|
;; - highlight/select the source and the current destination.
|
|
|
|
|
|
|
|
(defun mpc-drag-n-drop (event)
|
|
|
|
"DWIM for a drag EVENT."
|
|
|
|
(interactive "e")
|
|
|
|
(let* ((start (event-start event))
|
|
|
|
(end (event-end event))
|
|
|
|
(start-buf (window-buffer (posn-window start)))
|
|
|
|
(end-buf (window-buffer (posn-window end)))
|
|
|
|
(songs
|
|
|
|
(with-current-buffer start-buf
|
|
|
|
(goto-char (posn-point start))
|
|
|
|
(if (get-text-property (point) 'mpc-select)
|
|
|
|
;; FIXME: actually we should only consider the constraints
|
|
|
|
;; corresponding to the selection in this particular buffer.
|
|
|
|
(mpc-songs-selection)
|
|
|
|
(cond
|
|
|
|
((and (derived-mode-p 'mpc-songs-mode)
|
|
|
|
(get-text-property (point) 'mpc-file))
|
|
|
|
(list (cons (get-text-property (point) 'mpc-file)
|
|
|
|
(get-text-property (point) 'mpc-file-pos))))
|
|
|
|
((and mpc-tag (not (mpc-tagbrowser-all-p)))
|
|
|
|
(mapcar (lambda (song)
|
|
|
|
(list (cdr (assq 'file song))))
|
|
|
|
(mpc-cmd-find
|
|
|
|
mpc-tag
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
(line-end-position)))))
|
|
|
|
(t
|
|
|
|
(error "Unsupported starting position for drag'n'drop gesture")))))))
|
|
|
|
(with-current-buffer end-buf
|
|
|
|
(goto-char (posn-point end))
|
|
|
|
(cond
|
|
|
|
((eq mpc-tag 'Playlist)
|
|
|
|
;; Adding elements to a named playlist.
|
|
|
|
(let ((playlist (if (or (mpc-tagbrowser-all-p)
|
|
|
|
(and (bolp) (eolp)))
|
|
|
|
(error "Not a playlist")
|
|
|
|
(buffer-substring (line-beginning-position)
|
|
|
|
(line-end-position)))))
|
2021-04-24 19:57:22 +00:00
|
|
|
(mpc-cmd-add (mapcar #'car songs) playlist)
|
2009-12-01 04:04:33 +00:00
|
|
|
(message "Added %d songs to %s" (length songs) playlist)
|
|
|
|
(if (member playlist
|
|
|
|
(cdr (assq 'Playlist (mpc-constraints-get-current))))
|
|
|
|
(mpc-songs-refresh))))
|
|
|
|
((derived-mode-p 'mpc-songs-mode)
|
|
|
|
(cond
|
|
|
|
((null mpc-songs-playlist)
|
|
|
|
(error "The songs shown do not belong to a playlist"))
|
|
|
|
((eq start-buf end-buf)
|
|
|
|
;; Moving songs within the shown playlist.
|
|
|
|
(let ((dest-pos (get-text-property (point) 'mpc-file-pos)))
|
2021-04-24 19:57:22 +00:00
|
|
|
(mpc-cmd-move (mapcar #'cdr songs) dest-pos mpc-songs-playlist)
|
2009-12-01 04:04:33 +00:00
|
|
|
(message "Moved %d songs" (length songs))))
|
|
|
|
(t
|
|
|
|
;; Adding songs to the shown playlist.
|
|
|
|
(let ((dest-pos (get-text-property (point) 'mpc-file-pos))
|
|
|
|
(pl (if (stringp mpc-songs-playlist)
|
|
|
|
(mpc-cmd-find 'Playlist mpc-songs-playlist)
|
|
|
|
(mpc-proc-cmd-to-alist "playlist"))))
|
|
|
|
;; MPD's protocol does not let us add songs at a particular
|
|
|
|
;; position in a playlist, so we first have to add them to the
|
|
|
|
;; end, and then move them to their final destination.
|
2021-04-24 19:57:22 +00:00
|
|
|
(mpc-cmd-add (mapcar #'car songs) mpc-songs-playlist)
|
2009-12-01 04:04:33 +00:00
|
|
|
(mpc-cmd-move (let ((poss '()))
|
|
|
|
(dotimes (i (length songs))
|
2021-04-24 19:57:22 +00:00
|
|
|
(push (+ i (length pl)) poss))
|
2014-09-22 13:42:57 +00:00
|
|
|
(nreverse poss))
|
|
|
|
dest-pos mpc-songs-playlist)
|
2009-12-01 04:04:33 +00:00
|
|
|
(message "Added %d songs" (length songs)))))
|
|
|
|
(mpc-songs-refresh))
|
|
|
|
(t
|
|
|
|
(error "Unsupported drag'n'drop gesture"))))))
|
|
|
|
|
|
|
|
;;; Toplevel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defcustom mpc-frame-alist '((name . "MPC") (tool-bar-lines . 1)
|
|
|
|
(font . "Sans"))
|
|
|
|
"Alist of frame parameters for the MPC frame."
|
|
|
|
:type 'alist)
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun mpc ()
|
|
|
|
"Main entry point for MPC."
|
|
|
|
(interactive
|
|
|
|
(progn
|
|
|
|
(if current-prefix-arg
|
2015-09-03 15:47:31 +00:00
|
|
|
;; FIXME: We should provide some completion here, especially for the
|
|
|
|
;; case where the user specifies a local socket/file name.
|
2020-09-06 20:59:48 +00:00
|
|
|
(setq mpc-host (read-string
|
|
|
|
(format-prompt "MPD host and port" mpc-host)
|
|
|
|
nil nil mpc-host)))
|
2009-12-01 04:04:33 +00:00
|
|
|
nil))
|
|
|
|
(let* ((song-buf (mpc-songs-buf))
|
|
|
|
(song-win (get-buffer-window song-buf 0)))
|
|
|
|
(if song-win
|
|
|
|
(select-window song-win)
|
Do not call to `selected-window' where it is assumed by default.
Affected functions are `window-minibuffer-p', `window-dedicated-p',
`window-hscroll', `window-width', `window-height', `window-buffer',
`window-frame', `window-start', `window-point', `next-window'
and `window-display-table'.
* abbrev.el (abbrev--default-expand):
* bs.el (bs--show-with-configuration):
* buff-menu.el (Buffer-menu-mouse-select):
* calc/calc.el (calc):
* calendar/calendar.el (calendar-generate-window):
* calendar/diary-lib.el (diary-simple-display, diary-show-all-entries)
(diary-make-entry):
* comint.el (send-invisible, comint-dynamic-complete-filename)
(comint-dynamic-simple-complete, comint-dynamic-list-completions):
* completion.el (complete):
* dabbrev.el (dabbrev-expand, dabbrev--make-friend-buffer-list):
* disp-table.el (describe-current-display-table):
* doc-view.el (doc-view-insert-image):
* ebuff-menu.el (Electric-buffer-menu-mouse-select):
* ehelp.el (with-electric-help):
* emacs-lisp/easy-mmode.el (easy-mmode-define-navigation):
* emacs-lisp/edebug.el (edebug-two-window-p, edebug-pop-to-buffer):
* emacs-lisp/helper.el (Helper-help-scroller):
* emulation/cua-base.el (cua--post-command-handler-1):
* eshell/esh-mode.el (eshell-output-filter):
* ffap.el (ffap-gnus-wrapper):
* help-macro.el (make-help-screen):
* hilit-chg.el (highlight-compare-buffers):
* hippie-exp.el (hippie-expand, try-expand-dabbrev-visible):
* hl-line.el (global-hl-line-highlight):
* icomplete.el (icomplete-simple-completing-p):
* isearch.el (isearch-done):
* jit-lock.el (jit-lock-stealth-fontify):
* mail/rmailsum.el (rmail-summary-scroll-msg-up):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* mpc.el (mpc-tagbrowser, mpc):
* net/rcirc.el (rcirc-any-buffer):
* play/gomoku.el (gomoku-max-width, gomoku-max-height):
* play/landmark.el (landmark-max-width, landmark-max-height):
* play/zone.el (zone):
* progmodes/compile.el (compilation-goto-locus):
* progmodes/ebrowse.el (ebrowse-view/find-file-and-search-pattern):
* progmodes/etags.el (find-tag-other-window):
* progmodes/fortran.el (fortran-column-ruler):
* progmodes/gdb-mi.el (gdb-mouse-toggle-breakpoint-fringe):
* progmodes/verilog-mode.el (verilog-point-text):
* reposition.el (reposition-window):
* rot13.el (toggle-rot13-mode):
* server.el (server-switch-buffer):
* shell.el (shell-dynamic-complete-command)
(shell-dynamic-complete-environment-variable):
* simple.el (insert-buffer, set-selective-display)
(delete-completion-window):
* speedbar.el (speedbar-timer-fn, speedbar-center-buffer-smartly)
(speedbar-recenter):
* startup.el (fancy-splash-head):
* textmodes/ispell.el (ispell-command-loop):
* textmodes/makeinfo.el (makeinfo-compilation-sentinel-region):
* tutorial.el (help-with-tutorial):
* vc/add-log.el (add-change-log-entry):
* vc/compare-w.el (compare-windows):
* vc/ediff-help.el (ediff-indent-help-message):
* vc/ediff-util.el (ediff-setup-control-buffer, ediff-position-region):
* vc/ediff-wind.el (ediff-skip-unsuitable-frames)
(ediff-setup-control-frame):
* vc/emerge.el (emerge-position-region):
* vc/pcvs-util.el (cvs-bury-buffer):
* window.el (walk-windows, mouse-autoselect-window-select):
* winner.el (winner-set-conf, winner-undo): Related users changed.
2013-08-05 14:26:57 +00:00
|
|
|
(if (or (window-dedicated-p) (window-minibuffer-p))
|
2009-12-01 04:04:33 +00:00
|
|
|
(ignore-errors (select-frame (make-frame mpc-frame-alist)))
|
|
|
|
(with-current-buffer song-buf
|
2013-03-29 14:23:24 +00:00
|
|
|
(setq-local mpc-previous-window-config
|
|
|
|
(current-window-configuration))))
|
2009-12-01 04:04:33 +00:00
|
|
|
(let* ((win1 (selected-window))
|
|
|
|
(win2 (split-window))
|
|
|
|
(tags mpc-browser-tags))
|
|
|
|
(unless tags (error "Need at least one entry in `mpc-browser-tags'"))
|
|
|
|
(set-window-buffer win2 song-buf)
|
|
|
|
(set-window-dedicated-p win2 'soft)
|
|
|
|
(mpc-status-buffer-show)
|
|
|
|
(while
|
|
|
|
(progn
|
|
|
|
(set-window-buffer win1 (mpc-tagbrowser-buf (pop tags)))
|
|
|
|
(set-window-dedicated-p win1 'soft)
|
|
|
|
tags)
|
|
|
|
(setq win1 (split-window win1 nil 'horiz)))))
|
|
|
|
(balance-windows-area))
|
|
|
|
(mpc-songs-refresh)
|
|
|
|
(mpc-status-refresh))
|
|
|
|
|
|
|
|
(provide 'mpc)
|
|
|
|
|
|
|
|
;;; mpc.el ends here
|