{"id":2671,"date":"2014-05-09T08:54:46","date_gmt":"2014-05-09T12:54:46","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=2671"},"modified":"2014-05-09T08:54:49","modified_gmt":"2014-05-09T12:54:49","slug":"guessing-file-applications-in-dired","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=2671","title":{"rendered":"Guessing File Applications in Dired"},"content":{"rendered":"<p> One of the really great tools in Emacs is the Dired\/Dired+ package. Recently, Mickey wrote a nice introduction to using Dired to run shell commands on files; I commented on that <a href=\"http:\/\/irreal.org\/blog\/?p=2612\">here<\/a>. The other day, by happenstance, I found myself needing to do just that. I wanted to display a series of PDF files from a directory to collect some information. Since I was in Emacs already to collect the data, I used Dired to list the directory and then used \u3010<kbd>!<\/kbd>\u3011 to invoke the PDF viewer. <\/p>\n<p> Emacs, of course, is pretty smart about things like that and suggested that I use <code>xpdf<\/code>. That would be precisely the right answer if I was working on one of my Linux machines but this was OS X and I really needed to invoke the <code>open<\/code> command. So I had to delete the suggestion and type in <code>open<\/code> for each file. Not really much trouble but later I thought that there was undoubtedly a way to control the suggestions. <\/p>\n<p> There is, of course. After grubbing around in <code>dired.el<\/code> for a bit, I found the answer. Dired uses an alist to match the default applications to file extensions but it has another&#x2014;empty by default&#x2014;alist, <code>dired-guess-shell-alist-user<\/code>, that it will prepend to the default list if it&#8217;s present. <\/p>\n<p> So I added <\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\">(<span style=\"color: #a020f0;\">setq<\/span> dired-guess-shell-alist-user      <span style=\"color: #b22222;\">;<\/span><span style=\"color: #b22222;\">quess shell command by file ext<\/span>\n      '((<span style=\"color: #8b2252;\">\"\\\\.pdf\\\\'\"<\/span> <span style=\"color: #8b2252;\">\"open\"<\/span>)\n        (<span style=\"color: #8b2252;\">\"\\\\.ps\\\\'\"<\/span> <span style=\"color: #8b2252;\">\"open\"<\/span>)))\n<\/pre>\n<\/p><\/div>\n<p> to my OS X specific configuration and now I get the proper suggestion when I run a shell command on PDF or PS files. How can you not love Emacs? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the really great tools in Emacs is the Dired\/Dired+ package. Recently, Mickey wrote a nice introduction to using Dired to run shell commands on files; I commented on that here. The other day, by happenstance, I found myself &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=2671\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-2671","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2671"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2671\/revisions"}],"predecessor-version":[{"id":2672,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2671\/revisions\/2672"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}