From 640de942984e86f1764a289d361b115f3980a0a2 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 21 Nov 2019 01:46:56 +0000 Subject: [PATCH 1/2] Use `user-region-p` instead of raw mark-active The latter does not work well when transient-mark-mode is nil, and leads to using the current region even if there's no active region. --- mingus.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mingus.el b/mingus.el index fdd5036..ac2db8a 100644 --- a/mingus.el +++ b/mingus.el @@ -12,7 +12,7 @@ ;; ....................but actually named after a man so named ;; -;; Copyright (C) 2006-2011, 2015, 2016 Niels Giesen ;; Author: Niels Giesen @@ -1718,7 +1718,7 @@ E.g.: \"Artist 3 my beautiful song\" is logically less than \"Artist 11 blue sea (defun mingus-mark-active () (if (featurep 'xemacs) (mark) - mark-active)) + (use-region-p))) (defun mingus-min:sec->secs (min:secs) "Convert MIN:SECS (a string) to seconds (an integer)." @@ -3354,11 +3354,12 @@ Actually it tries to retrieve any stream from a given url. (mingus-browse-top-level))))) (defun mingus-get-items () - (let ((items (unless mark-active - (list (mingus-get-details)))) - (beg (if mark-active (min (mark) (point)))) - (end (if mark-active (max (mark) (point))))) - (when mark-active + (let* ((markp (mingus-mark-active)) + (items (unless markp + (list (mingus-get-details)))) + (beg (if markp (min (mark) (point)))) + (end (if markp (max (mark) (point))))) + (when markp (save-excursion (goto-char end) (while @@ -4226,8 +4227,8 @@ It may also mean handling file:/// links." "Get everything under the region, sloppily. Region is between (beginning of line of) BEG and (beginning of line of) END." (interactive "r") - (let ((beg (if mark-active (_mingus-bol-at beg) (point-at-bol))) - (end (if mark-active (_mingus-bol-at end) (point-at-eol))) + (let ((beg (if (mingus-mark-active) (_mingus-bol-at beg) (point-at-bol))) + (end (if (mingus-mark-active) (_mingus-bol-at end) (point-at-eol))) results) (save-excursion (goto-char beg) From 940b9c81d3aa074fd058368fd1f94dc82830a5da Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 21 Nov 2019 02:02:44 +0000 Subject: [PATCH 2/2] Stop flickering (issues #26 and #30) with-current-buffer nows how to operate on a buffer without switching to it, or needing to save the current window configuration. --- mingus.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mingus.el b/mingus.el index ac2db8a..365d47b 100644 --- a/mingus.el +++ b/mingus.el @@ -2205,9 +2205,8 @@ Argument OVERRIDE defines whether to treat the situation as new." (condition-case nil (let ((pos (or pos (getf (mpd-get-status mpd-inter-conn) 'song)))) (and pos - (save-excursion - (save-window-excursion - (mingus-switch-to-playlist) + (with-current-buffer "*Mingus*" + (save-excursion (let (buffer-read-only) (mingus-goto-line (1+ pos)) (mingus-move-NP-mark