Permalink
Browse files

Issue #116 Fix and bind helm-c-open-file-with-default-tool in *find-f…

…iles and locate.

* helm-external (helm-run-or-raise): Always pipe proc.
* helm-files.el: Bind helm-c-open-file-with-default-tool in helm-find-files.
Fix action transformer, always place new action to end.
* helm-help.el add open file with default tool to doc.
* helm-utils.el (helm-c-open-file-with-default-tool): Fix for emacs24+ (always pipe proc).
  • Loading branch information...
thierryvolpiatto committed Sep 20, 2012
1 parent db04678 commit 32db807ef54e62ce61dce9d642cd6f3e3eefe573
Showing with 35 additions and 26 deletions.
  1. +2 −1 helm-external.el
  2. +19 −15 helm-files.el
  3. +2 −0 helm-help.el
  4. +1 −0 helm-locate.el
  5. +11 −10 helm-utils.el
View
@@ -87,7 +87,8 @@ When FILE argument is provided run EXE with FILE.
In this case EXE must be provided as \"EXE %s\"."
(lexical-let* ((real-com (car (split-string (replace-regexp-in-string
"%s" "" exe))))
- (proc (if file (concat real-com " " file) real-com)))
+ (proc (if file (concat real-com " " file) real-com))
+ process-connection-type)
(if (get-process proc)
(if helm-raise-command
(shell-command (format helm-raise-command real-com))
View
@@ -274,6 +274,7 @@ This happen only in `helm-find-files'."
(define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window)
(define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame)
(define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally)
+ (define-key map (kbd "C-c X") 'helm-ff-run-open-file-with-default-tool)
(define-key map (kbd "M-!") 'helm-ff-run-eshell-command-on-file)
(define-key map (kbd "C-=") 'helm-ff-run-ediff-file)
(define-key map (kbd "C-c =") 'helm-ff-run-ediff-merge-file)
@@ -374,6 +375,7 @@ Don't set it directly, use instead `helm-ff-auto-update-initial-value'.")
. helm-c-insert-file-name-completion-at-point)
("Open file externally `C-c C-x, C-u to choose'"
. helm-c-open-file-externally)
+ ("Open file with default tool" . helm-c-open-file-with-default-tool)
("Grep File(s) `M-g s, C-u Recurse'" . helm-find-files-grep)
("Zgrep File(s) `M-g z, C-u Recurse'" . helm-ff-zgrep)
("Switch to Eshell `M-e'" . helm-ff-switch-to-eshell)
@@ -905,6 +907,13 @@ See `helm-ff-serial-rename-1'."
(when helm-alive-p
(helm-c-quit-and-execute-action 'helm-c-open-file-externally)))
+;;;###autoload
+(defun helm-ff-run-open-file-with-default-tool ()
+ "Run open file externally command action from `helm-c-source-find-files'."
+ (interactive)
+ (when helm-alive-p
+ (helm-c-quit-and-execute-action 'helm-c-open-file-with-default-tool)))
+
(defun helm-ff-locate (candidate)
"Locate action function for `helm-find-files'."
(helm-locate-set-command)
@@ -1608,31 +1617,26 @@ is non--nil."
"Action transformer for `helm-c-source-find-files'."
(cond ((with-helm-current-buffer
(eq major-mode 'message-mode))
- (append (subseq actions 0 4)
- '(("Gnus attach file(s)" . helm-ff-gnus-attach-files))
- (subseq actions 4)))
+ (append actions
+ '(("Gnus attach file(s)" . helm-ff-gnus-attach-files))))
((string-match (image-file-name-regexp) candidate)
- (append (subseq actions 0 4)
+ (append actions
'(("Rotate image right `M-r'" . helm-ff-rotate-image-right)
- ("Rotate image left `M-l'" . helm-ff-rotate-image-left))
- (subseq actions 4)))
+ ("Rotate image left `M-l'" . helm-ff-rotate-image-left))))
((string-match "\.el$" (helm-aif (helm-marked-candidates)
(car it) candidate))
- (append (subseq actions 0 4)
+ (append actions
'(("Byte compile lisp file(s) `M-B, C-u to load'"
. helm-find-files-byte-compile)
- ("Load File(s) `M-L'" . helm-find-files-load-files))
- (subseq actions 4)))
+ ("Load File(s) `M-L'" . helm-find-files-load-files))))
((and (string-match "\.html?$" candidate)
(file-exists-p candidate))
- (append (subseq actions 0 4)
- '(("Browse url file" . browse-url-of-file))
- (subseq actions 5)))
+ (append actions
+ '(("Browse url file" . browse-url-of-file))))
((or (string= (file-name-extension candidate) "pdf")
(string= (file-name-extension candidate) "PDF"))
- (append (subseq actions 0 4)
- '(("Pdfgrep File(s)" . helm-ff-pdfgrep))
- (subseq actions 5)))
+ (append actions
+ '(("Pdfgrep File(s)" . helm-ff-pdfgrep))))
(t actions)))
(defun helm-ff-gnus-attach-files (candidate)
View
@@ -230,6 +230,7 @@ This list is customizable, see `helm-buffers-favorite-modes'.
\\[helm-ff-run-switch-other-window]\t\t->Switch other window.
\\[helm-ff-run-switch-other-frame]\t\t->Switch other frame.
\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose).
+\\[helm-ff-run-open-file-with-default-tool]\t\t->Open file externally with default tool.
\\[helm-ff-rotate-left-persistent]\t\t->Rotate Image Left.
\\[helm-ff-rotate-right-persistent]\t\t->Rotate Image Right.
\\[helm-find-files-down-one-level]\t\t->Go down precedent directory.
@@ -295,6 +296,7 @@ This list is customizable, see `helm-buffers-favorite-modes'.
\\[helm-ff-run-etags]\t\t->Run etags (C-u use tap, C-u C-u reload DB).
\\[helm-yank-text-at-point]\t\t->Yank text at point.
\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose).
+\\[helm-ff-run-open-file-with-default-tool]\t\t->Open file externally with default tool.
\nLocate tips:
You can add after writing search pattern any of the locate command line options.
e.g -b, -e, -n <number>...etc.
View
@@ -96,6 +96,7 @@ the opposite of \"locate\" command."
(define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window)
(define-key map (kbd "M-i") 'helm-ff-properties-persistent)
(define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally)
+ (define-key map (kbd "C-c X") 'helm-ff-run-open-file-with-default-tool)
(define-key map (kbd "M-.") 'helm-ff-run-etags)
(define-key map (kbd "C-w") 'helm-yank-text-at-point)
(define-key map (kbd "C-c ?") 'helm-generic-file-help)
View
@@ -614,16 +614,17 @@ Useful in dired buffers when there is inserted subdirs."
(defun helm-c-open-file-with-default-tool (file)
"Open FILE with the default tool on this platform."
- (if (eq system-type 'windows-nt)
- (helm-w32-shell-execute-open-file file)
- (start-process "helm-c-open-file-with-default-tool"
- nil
- (cond ((eq system-type 'gnu/linux)
- "xdg-open")
- ((or (eq system-type 'darwin) ;; Mac OS X
- (eq system-type 'macos)) ;; Mac OS 9
- "open"))
- file)))
+ (let (process-connection-type)
+ (if (eq system-type 'windows-nt)
+ (helm-w32-shell-execute-open-file file)
+ (start-process "helm-c-open-file-with-default-tool"
+ nil
+ (cond ((eq system-type 'gnu/linux)
+ "xdg-open")
+ ((or (eq system-type 'darwin) ;; Mac OS X
+ (eq system-type 'macos)) ;; Mac OS 9
+ "open"))
+ file))))
(defun helm-c-open-dired (file)
"Opens a dired buffer in FILE's directory. If FILE is a

0 comments on commit 32db807

Please sign in to comment.