[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 124/287: Refactor ergoemacs-open-in-external-app
From: |
Matthew Fidler |
Subject: |
[elpa] 124/287: Refactor ergoemacs-open-in-external-app |
Date: |
Wed, 02 Jul 2014 14:45:15 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit f0e2d616dca04dad89b5d437c69f94cca666d2d3
Author: Matthew L. Fidler <address@hidden>
Date: Wed Jun 18 07:02:44 2014 -0500
Refactor ergoemacs-open-in-external-app
---
ergoemacs-functions.el | 50 ++++++++++++++++++++++++++---------------------
1 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el
index d9d3c3d..0fcb84f 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -1216,39 +1216,38 @@ Emacs buffers are those whose name starts with *."
(switch-to-buffer buf)
(funcall (and initial-major-mode))
(setq buffer-offer-save t)))
-;; note: emacs won't offer to save a buffer that's
-;; not associated with a file,
-;; even if buffer-modified-p is true.
-;; One work around is to define your own my-kill-buffer function
-;; that wraps around kill-buffer, and check on the buffer modification
-;; status to offer save
-;; This custome kill buffer is close-current-buffer.
+(defcustom ergoemacs-maximum-number-of-file-to-open 5
+ "Maximum number of files to open"
+ :type 'integerp
+ :group 'ergoemacs-mode)
(declare-function dired-get-marked-files "dired.el")
(declare-function w32-shell-execute "w32fns.c")
(defun ergoemacs-open-in-external-app (&optional file)
"Open the current file or dired marked files in external app."
(interactive)
- (let ( doIt
- (myFileList
+ (let* ((my-file-list
(cond
((string-equal major-mode "dired-mode") (dired-get-marked-files))
((string-equal major-mode "locate-mode") (dired-get-marked-files))
((not file) (list (buffer-file-name)))
- (file (list file)))))
-
- (setq doIt (if (<= (length myFileList) 5)
- t
- (y-or-n-p "Open more than 5 files? ") ) )
-
- (when doIt
+ (file (list file))))
+ (do-it (or (<= (length my-file-list)
ergoemacs-maximum-number-of-file-to-open)
+ (>= 0 ergoemacs-maximum-number-of-file-to-open)
+ (y-or-n-p (format "Open more than %s files? "
ergoemacs-maximum-number-of-file-to-open)))))
+ (when do-it
(cond
- ((string-equal system-type "windows-nt")
- (mapc (lambda (fPath) (w32-shell-execute "open"
(replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList))
- ((string-equal system-type "darwin")
- (mapc (lambda (fPath) (shell-command (format "open \"%s\"" fPath)) )
myFileList) )
- ((string-equal system-type "gnu/linux")
- (mapc (lambda (fPath) (let ((process-connection-type nil))
(start-process "" nil "xdg-open" fPath)) ) myFileList) ) ) ) ) )
+ ((eq system-type 'windows-nt)
+ (dolist (f-path my-file-list)
+ (w32-shell-execute
+ "open" (replace-regexp-in-string "/" "\\" f-path t t))))
+ ((eq system-type 'darwin)
+ (dolist (f-path my-file-list)
+ (shell-command (format "open \"%s\"" f-path))))
+ ((eq system-type 'gnu/linux)
+ (dolist (f-path my-file-list)
+ (let (process-connection-type)
+ (start-process "" nil "xdg-open" f-path))))))))
(defun ergoemacs-open-in-desktop ()
"Show current file in desktop (OS's file manager)."
@@ -1265,6 +1264,13 @@ Emacs buffers are those whose name starts with *."
(defvar ergoemacs-recently-closed-buffers (cons nil nil) "A list of recently
closed buffers. The max number to track is controlled by the variable
`ergoemacs-recently-closed-buffers-max'.")
(defvar ergoemacs-recently-closed-buffers-max 30 "The maximum length for
`ergoemacs-recently-closed-buffers'.")
+;; note: emacs won't offer to save a buffer that's
+;; not associated with a file,
+;; even if buffer-modified-p is true.
+;; One work around is to define your own my-kill-buffer function
+;; that wraps around kill-buffer, and check on the buffer modification
+;; status to offer save
+;; This custome kill buffer is close-current-buffer.
(defvar ergoemacs-single-command-keys)
(declare-function ergoemacs-get-override-function "ergoemacs-shortcuts.el")
(declare-function minibuffer-keyboard-quit "delsel.el")
- [elpa] 102/287: Require the libraries that may be needed..., (continued)
- [elpa] 102/287: Require the libraries that may be needed..., Matthew Fidler, 2014/07/02
- [elpa] 128/287: Fix byte compile issues and remove gaia., Matthew Fidler, 2014/07/02
- [elpa] 139/287: Make TEST_DIR first, Matthew Fidler, 2014/07/02
- [elpa] 204/287: Allow ergoemacs-key to work outside of themes again, Matthew Fidler, 2014/07/02
- [elpa] 141/287: Add back ergoemacs-fixed-key and ergoemacs-key compatability., Matthew Fidler, 2014/07/02
- [elpa] 200/287: Declare undo-tree, Matthew Fidler, 2014/07/02
- [elpa] 111/287: No compiler warnings for ergoemacs-menus.el, Matthew Fidler, 2014/07/02
- [elpa] 112/287: Fix last compiler issue for ergoemacs-menus.el, Matthew Fidler, 2014/07/02
- [elpa] 91/287: All tests pass; ido-vertical doesn't have right keys, Matthew Fidler, 2014/07/02
- [elpa] 118/287: Move macros from ergoemacs-theme-engine, Matthew Fidler, 2014/07/02
- [elpa] 124/287: Refactor ergoemacs-open-in-external-app,
Matthew Fidler <=
- [elpa] 138/287: Make the test directory., Matthew Fidler, 2014/07/02
- [elpa] 109/287: Add ergoemacs-macros for all macros., Matthew Fidler, 2014/07/02
- [elpa] 121/287: Remove cl dependence for ergoemacs-theme-engine.el, Matthew Fidler, 2014/07/02
- [elpa] 107/287: Remove save-variable-state, Matthew Fidler, 2014/07/02
- [elpa] 197/287: Merge branch 'master' of github.com:ergoemacs/ergoemacs-mode, Matthew Fidler, 2014/07/02
- [elpa] 106/287: Fix many byte-compile warnings in ergoemacs-extras.el, Matthew Fidler, 2014/07/02
- [elpa] 95/287: Revert "Fixed shortcut keys.", Matthew Fidler, 2014/07/02
- [elpa] 90/287: Allow unset keys to work too, Matthew Fidler, 2014/07/02
- [elpa] 115/287: Take away warnings from ergoemacs-mode.el, Matthew Fidler, 2014/07/02
- [elpa] 192/287: Add ergoemacs-test-layout, Matthew Fidler, 2014/07/02