all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] lisp/mpc.el (mpc-file-local-copy): check more config locations
@ 2015-09-07 23:31 Mark Oteiza
  2015-09-07 23:31 ` [PATCH 2/3] lisp/mpc.el (mpc-file-local-copy): check for absolute path Mark Oteiza
  2015-09-07 23:31 ` [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p Mark Oteiza
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Oteiza @ 2015-09-07 23:31 UTC (permalink / raw)
  To: emacs-devel; +Cc: Mark Oteiza

---
Updated according to mpd(1) of mpd version 0.19.10

 lisp/mpc.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index fdc5aee..740b865 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -910,7 +910,11 @@ If PLAYLIST is t or nil or missing, use the main playlist."
   ;; Try to set mpc-mpd-music-directory.
   (when (and (null mpc-mpd-music-directory)
              (string-match "\\`localhost" mpc-host))
-    (let ((files '("~/.mpdconf" "/etc/mpd.conf"))
+    (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"))
           file)
       (while (and files (not file))
         (if (file-exists-p (car files)) (setq file (car files)))
-- 
2.5.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] lisp/mpc.el (mpc-file-local-copy): check for absolute path
  2015-09-07 23:31 [PATCH 1/3] lisp/mpc.el (mpc-file-local-copy): check more config locations Mark Oteiza
@ 2015-09-07 23:31 ` Mark Oteiza
  2015-09-07 23:31 ` [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p Mark Oteiza
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Oteiza @ 2015-09-07 23:31 UTC (permalink / raw)
  To: emacs-devel; +Cc: Mark Oteiza

---
 lisp/mpc.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index 740b865..643aa0e 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -909,7 +909,8 @@ If PLAYLIST is t or nil or missing, use the main playlist."
 (defun mpc-file-local-copy (file)
   ;; Try to set mpc-mpd-music-directory.
   (when (and (null mpc-mpd-music-directory)
-             (string-match "\\`localhost" mpc-host))
+             (or (string-match "\\`localhost" mpc-host)
+                 (file-name-absolute-p mpc-host)))
     (let ((files `(,(let ((xdg (getenv "XDG_CONFIG_HOME")))
                       (concat (if (and xdg (file-name-absolute-p xdg))
                                   xdg "~/.config")
-- 
2.5.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p
  2015-09-07 23:31 [PATCH 1/3] lisp/mpc.el (mpc-file-local-copy): check more config locations Mark Oteiza
  2015-09-07 23:31 ` [PATCH 2/3] lisp/mpc.el (mpc-file-local-copy): check for absolute path Mark Oteiza
@ 2015-09-07 23:31 ` Mark Oteiza
  2015-09-08  1:16   ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Oteiza @ 2015-09-07 23:31 UTC (permalink / raw)
  To: emacs-devel; +Cc: Mark Oteiza

---
make-network-process doesn't do tilde expansion, so the "absolute path" needs
to be expanded

 lisp/mpc.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/mpc.el b/lisp/mpc.el
index 643aa0e..33a807c 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -268,7 +268,10 @@ defaults to 6600 and HOST defaults to localhost."
                 (if (string-match "[^[:digit:]]" v)
                     (string-to-number v)
                   v)))))
-    (when (string-prefix-p "/" host)    ;FIXME: Use file-name-absolute-p?
+    (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))
       (setq local t))
 
     (mpc--debug "Connecting to %s:%s..." host port)
-- 
2.5.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p
  2015-09-07 23:31 ` [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p Mark Oteiza
@ 2015-09-08  1:16   ` Stefan Monnier
  2015-09-08  1:57     ` Mark Oteiza
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-09-08  1:16 UTC (permalink / raw)
  To: Mark Oteiza; +Cc: emacs-devel

> -    (when (string-prefix-p "/" host)    ;FIXME: Use file-name-absolute-p?
> +    (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))

So do you think using file-name-absolute-p is better?
I left it as a FIXME, because I simply didn't know the answer.

If you set $MPD_HOST to "~/.mpdsocket" do other MPD clients handle
it correctly?

What about under w32?


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p
  2015-09-08  1:16   ` Stefan Monnier
@ 2015-09-08  1:57     ` Mark Oteiza
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Oteiza @ 2015-09-08  1:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On 07/09/15 at 09:16pm, Stefan Monnier wrote:
> > -    (when (string-prefix-p "/" host)    ;FIXME: Use file-name-absolute-p?
> > +    (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))
> 
> So do you think using file-name-absolute-p is better?
> I left it as a FIXME, because I simply didn't know the answer.

The only reasons I imagine it's better is because of readability and
file_name_absolute_p has platform specifics. The latter reason is likely
a silly one, regarding w32.

> If you set $MPD_HOST to "~/.mpdsocket" do other MPD clients handle
> it correctly?

No, which is why I initially just did string-prefix-p. However, normally
when one sets MPD_HOST in, for instance, a shell config e.g.

  export MPD_HOST=~/.mpdsocket

the shell does the expansion of the ~ for us.  No mpd client I know of
(I've only tried mpc(1) and ncmpcpp) does tilde expansion.  What the
change is good for is letting someone set the defcustom mpc-host to the
string "~/.mpdsocket" and it working, because Emacs is doing the tilde
expansion.

I think that file-name-absolute-p treating paths beginning with ~ as
absolute is a little weird because it isn't really an absolute path, at
least not until the tilde (or ~user/) is expanded into the path it
represents.  I figured I'd work with it, though.

> What about under w32?

I don't even know what the analog to UNIX domain sockets is on windows,
if there is one.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-08  1:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-07 23:31 [PATCH 1/3] lisp/mpc.el (mpc-file-local-copy): check more config locations Mark Oteiza
2015-09-07 23:31 ` [PATCH 2/3] lisp/mpc.el (mpc-file-local-copy): check for absolute path Mark Oteiza
2015-09-07 23:31 ` [PATCH 3/3] lisp/mpc.el (mpc--proc-connect): use file-name-absolute-p Mark Oteiza
2015-09-08  1:16   ` Stefan Monnier
2015-09-08  1:57     ` Mark Oteiza

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.