Seiji Zenitani
zenit****@users*****
2005年 12月 17日 (土) 11:33:16 JST
Index: CarbonEmacsPackage/GPL/mac/mac-drag-N-drop.el diff -u CarbonEmacsPackage/GPL/mac/mac-drag-N-drop.el:1.1 CarbonEmacsPackage/GPL/mac/mac-drag-N-drop.el:removed --- CarbonEmacsPackage/GPL/mac/mac-drag-N-drop.el:1.1 Sun Oct 23 13:18:04 2005 +++ CarbonEmacsPackage/GPL/mac/mac-drag-N-drop.el Sat Dec 17 11:33:16 2005 @@ -1,233 +0,0 @@ -;;; mac-drag-N-drop.el --- an alternative to mac-drag-n-drop - -;; Copyright (C) 2003-2005 Seiji Zenitani <zenit****@mac*****> - -;; Author: Seiji Zenitani <zenit****@mac*****> -;; Based on: mac-win.el by Andrew Choi <akoch****@mac*****> -;; Version: v20050106 -;; Keywords: tools -;; Created: 2003-04-27 -;; Compatibility: Emacs 21, Mac OS X -;; URL(en): http://home.att.ne.jp/alpha/z123/elisp-e.html -;; URL(jp): http://macwiki.sourceforge.jp/cgi-bin/wiki.cgi?mac-drag-N-drop - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary - -;; This package provides `mac-drag-N-drop' function, -;; a modified version of `mac-drag-n-drop' in mac-win.el for Mac OS X. -;; By editing `mac-drag-N-drop-string-alist', -;; the user can insert pre-defined strings at point when a file is dropped. - -;;; Usage: - -;; (require 'mac-drag-N-drop) -;; (local-set-key [drag-n-drop] 'mac-drag-N-drop) - -;; Due to improvement of `x-dnd' feature, -;; global-set-key is no-longer recommended. - - -;;; Code: - -(defvar mac-drag-N-drop-string-alist '( - (c++-mode . ( - ("\\.h\\'" . "#include <%f>") - )) - ("\\.tex\\'" . ( - ("\\.tex\\'" . "\\input{%r}\n") - ("\\.cls\\'" . "\\documentclass{%f}\n") - ("\\.sty\\'" . "\\usepackage{%f}\n") - ("\\.eps\\'" . "\\includegraphics[]{%r}\n") - ("\\.ps\\'" . "\\includegraphics[]{%r}\n") - ("\\.pdf\\'" . (mac-drag-N-drop-read-LEE-pdf file)) ; LaTeX Equation Editor - ("\\.pdf\\'" . "\\includegraphics[]{%r}\n") - ("\\.jpg\\'" . "\\includegraphics[]{%r}\n") - ("\\.png\\'" . "\\includegraphics[]{%r}\n") - )) - ("\\.html?\\'" . ( - ("\\.gif\\'" . "<img src=\"%r\">\n") - ("\\.jpg\\'" . "<img src=\"%r\">\n") - ("\\.png\\'" . "<img src=\"%r\">\n") - ("\\.css\\'" . "<link rel=\"stylesheet\" type=\"text/css\" href=\"%r\">\n" ) - ("\\.js\\'" . "<script type=\"text/javascript\" src=\"%r\"></script>\n" ) - (".*" . "<a href=\"%r\">%f</a>\n") - )) - (shell-mode . ( - (".*" . "%F") - )) - (ome-smail-mode . ( ; for OME project <http://mac-ome.jp/> - (".*" . "Attachment: %F\n") - )) - )) - -(defvar mac-drag-N-drop-replace-alist '( - ("%F" . file) - ("%f" . (file-name-nondirectory file)) - ("%r" . (file-relative-name file (file-name-directory (buffer-file-name)))) - ("%n" . (file-name-sans-extension (file-name-nondirectory file))) - ("%e" . (file-name-extension file)) - )) - -(defvar mac-drag-N-drop-local-string-alist nil) -(make-variable-buffer-local 'mac-drag-N-drop-local-string-alist) - - -(defun mac-drag-N-drop-setup () - "Document forthcoming..." - (interactive) - (let ((alist mac-drag-N-drop-string-alist)) - (while alist - (let ((condition (caar alist)) - (strlist (cdar alist))) - (if (or (and (symbolp condition) - (equal condition major-mode) ) - (and (stringp condition) - (stringp (buffer-file-name)) - (string-match condition (buffer-file-name))) ) - (progn - (setq mac-drag-N-drop-local-string-alist strlist) - (setq alist nil) - )) - ) - (setq alist (cdr alist)) - ) - )) - -;; originally from `mac-drag-n-drop' in mac-win.el -(defun mac-drag-N-drop (event) - "Document forthcoming..." - (interactive "e") -; (save-excursion - ;; Make sure the drop target has positive co-ords - ;; before setting the selected frame - otherwise it - ;; won't work. <skx****@tardi*****> - (let* ((window (posn-window (event-start event))) - (coords (posn-x-y (event-start event))) - (x (car coords)) - (y (cdr coords))) - (if (and (> x 0) (> y 0)) - (progn - (set-frame-selected-window nil window) - (goto-char (posn-point (event-start event))) - (mapcar - '(lambda (file) - (mac-drag-N-drop-execute - (decode-coding-string - file - (or file-name-coding-system - default-file-name-coding-system)))) - (car (cdr (cdr event))))) - (mapcar - '(lambda (file) - (find-file - (decode-coding-string - file - (or file-name-coding-system - default-file-name-coding-system)))) - (car (cdr (cdr event)))) - ) - (raise-frame) - (recenter) - )) - ;) - - -(defun mac-drag-N-drop-execute (file) - "Document forthcoming..." - (interactive "f") - (mac-drag-N-drop-setup) - (let( (alist mac-drag-N-drop-local-string-alist) - (case-fold-search nil) - (my-string nil) - (not-yet t) ) - (while (and alist not-yet) - (if (string-match (caar alist) file) - (progn - (setq my-string (cdar alist)) - (if (not (stringp my-string)) - (setq my-string (eval (cdar alist)))) - (if (stringp my-string) - (insert (mac-drag-N-drop-string my-string)) - ) - (when my-string - (setq alist nil) - (setq not-yet nil) - ) - )) - (setq alist (cdr alist)) - ) - (if not-yet (find-file file)) - )) - -(defun mac-drag-N-drop-read-LEE-pdf (file) - "read source lines from LaTeX Equation Editor's PDF file." - (interactive "P") - (with-temp-buffer - (let ((case-fold-search nil) - (fsize (elt (file-attributes file) 7)) ) - (if (> fsize (* 1024 1024)) nil - (progn - (insert-file-contents file) - (replace-string "ESslash" "\\") - (goto-char (point-min)) - (replace-string "ESleftbrack" "{") - (goto-char (point-min)) - (replace-string "ESrightbrack" "}") - (goto-char (point-min)) - (replace-string "ESdollar" "$") - (goto-char (point-min)) - (and (re-search-forward "ESannot\\(.*\\)ESannotend" (point-max) t) - (match-string-no-properties 1)) - ))))) - -(defun mac-drag-N-drop-string (arg) - "Document forthcoming..." - (interactive) - (let ((rlist mac-drag-N-drop-replace-alist)) - (while rlist - (while (string-match (caar rlist) arg) - (setq arg - (replace-match - (eval (cdar rlist)) t nil arg))) - (setq rlist (cdr rlist)) - ) - ) - arg) - - -(defun mac-drag-N-drop-read-vcf (file) - "This code is experimental." - (interactive "P") - (with-temp-buffer - (insert-file-contents file) - (let* ((case-fold-search nil) - (name - (and (re-search-forward "FN:\\(.*\\)" (point-max) - t) - (match-string-no-properties 1))) - (mail - (and (re-search-forward "EMAIL;.*type=pref:\\(.*\\)" (point-max) - t) - (match-string-no-properties 1))) ) - - (concat name " <" mail ">") - ))) - -(provide 'mac-drag-N-drop) - -;; mac-drag-N-drop.el ends here \ No newline at end of file Index: CarbonEmacsPackage/GPL/mac/mac-key-mode.el diff -u CarbonEmacsPackage/GPL/mac/mac-key-mode.el:1.5 CarbonEmacsPackage/GPL/mac/mac-key-mode.el:1.6 --- CarbonEmacsPackage/GPL/mac/mac-key-mode.el:1.5 Wed Dec 14 23:36:34 2005 +++ CarbonEmacsPackage/GPL/mac/mac-key-mode.el Sat Dec 17 11:33:16 2005 @@ -3,7 +3,7 @@ ;; Copyright (C) 2004-2005 Seiji Zenitani <zenit****@mac*****> ;; Author: Seiji Zenitani <zenit****@mac*****> -;; Version: v20051130 +;; Version: v20051215 ;; Keywords: tools, mac ;; Created: 2004-12-27 ;; Compatibility: Mac OS X (Carbon Emacs) @@ -56,16 +56,21 @@ :group 'mac :version "22.1") -(defvar mac-key-mode-backup-command-key-is-meta nil +(defvar mac-key-backup-command-key-is-meta nil "Do not use this variable.") -(defvar mac-key-mode-backup-pc-selection-mode nil +(defvar mac-key-backup-pc-selection-mode nil "Do not use this variable.") -(defvar mac-key-mode-use-htmlize-view (locate-library "htmlize-view") +(defvar mac-key-use-htmlize-view + (if (locate-library "htmlize-view") t nil) "Do not use this variable.") -(if mac-key-mode-use-htmlize-view +(if mac-key-use-htmlize-view (autoload 'htmlize-view-buffer "htmlize-view" nil t)) -(defcustom mac-key-mode-modify-file-menu-flag t +(defcustom mac-key-remote-file-regexp "\\`/[^/:]+:" + "*Regular expression matching file names on the remote host." + :group 'mac-key-mode + :type 'string) +(defcustom mac-key-modify-file-menu-p t "If non-nil, `mac-key-mode' addes several menu items to the File menu and the Edit menu in the menu bar." :group 'mac-key-mode @@ -77,6 +82,12 @@ when `mac-key-mode' is on." :group 'mac-key-mode :type 'string) +(defcustom mac-key-use-smartactivate-osax nil + "If non-nil, `mac-key-show-in-finder' takes advandage of +Kurita-san's SmartActivate osax. For more details, visit +http://homepage.mac.com/tkurita/scriptfactory/." + :group 'mac-key-mode + :type 'boolean) (defvar mac-key-mode-map (let ((map (make-sparse-keymap))) @@ -122,18 +133,18 @@ (if mac-key-mode (progn - (setq mac-key-mode-backup-command-key-is-meta mac-command-key-is-meta - mac-key-mode-backup-pc-selection-mode pc-selection-mode) + (setq mac-key-backup-command-key-is-meta mac-command-key-is-meta + mac-key-backup-pc-selection-mode pc-selection-mode) (setq mac-command-key-is-meta nil) (pc-selection-mode t) - (when mac-key-mode-modify-file-menu-flag + (when mac-key-modify-file-menu-p (define-key-after menu-bar-file-menu [mac-file-separator] '("--" . nil) 'recover-session) (define-key-after menu-bar-file-menu [mac-show-in-finder] '("Show In Finder" . mac-key-show-in-finder) 'mac-file-separator) (define-key-after menu-bar-file-menu [mac-open-terminal] '("Open Terminal" . mac-key-open-terminal) 'mac-show-in-finder) - (if mac-key-mode-use-htmlize-view + (if mac-key-use-htmlize-view (define-key-after menu-bar-file-menu [mac-htmlize-view-buffer] '("Preview In Browser" . htmlize-view-buffer) 'mac-show-in-finder) @@ -146,11 +157,11 @@ ) (progn - (setq mac-command-key-is-meta mac-key-mode-backup-command-key-is-meta) - (pc-selection-mode mac-key-mode-backup-pc-selection-mode) + (setq mac-command-key-is-meta mac-key-backup-command-key-is-meta) + (pc-selection-mode mac-key-backup-pc-selection-mode) (define-key global-map [menu-bar file mac-file-separator] nil) (define-key global-map [menu-bar file mac-show-in-finder] nil) - (if mac-key-mode-use-htmlize-view + (if mac-key-use-htmlize-view (define-key global-map [menu-bar file mac-htmlize-view-buffer] nil) ) (define-key global-map [menu-bar file mac-open-terminal] nil) @@ -198,34 +209,58 @@ (defun mac-key-show-in-finder () "Document forthcoming..." (interactive) - (let ((file nil)) + (let ((mode nil) + (file nil)) + (cond - ((and (local-variable-p 'dired-directory) - dired-directory - (string-match "\\.app/\\'" dired-directory)) - (setq file dired-directory)) - ((stringp (buffer-file-name)) - (setq file (buffer-file-name)))) + ((eq major-mode 'dired-mode) + (cond + ((string-match mac-key-remote-file-regexp dired-directory) + (message "remote directory")) + ((string-match "\\.app/\\'" dired-directory) + (setq file dired-directory) + (setq mode 'info)) + (t + (setq mode 'open)) + )) + ((boundp 'buffer-file-name) + (cond + ((string-match mac-key-remote-file-regexp buffer-file-name) + (message "remote file")) +;; ((string-match "^\\." (file-name-nondirectory buffer-file-name)) +;; (message "cannot show dot file")) + (t + (setq file buffer-file-name) + (setq mode 'info)) + )) + ) - (if file - (do-applescript - (format " + (cond + ((eq mode 'info) + (do-applescript + (format " try tell application \"Finder\" select (\"%s\" as POSIX file) - activate + %s end tell on error beep end try" - (if (eq selection-coding-system 'sjis-mac) - (replace-regexp-in-string - "\\\\" "\\\\\\\\" - (encode-coding-string file selection-coding-system)) + (if (eq selection-coding-system 'sjis-mac) + (replace-regexp-in-string + "\\\\" "\\\\\\\\" + (encode-coding-string file selection-coding-system)) (encode-coding-string file selection-coding-system)) - )) - (shell-command "/usr/bin/open .") - ))) + (if mac-key-use-smartactivate-osax + "ActivateProcess identifier \"com.apple.finder\"" + "activate") + ))) + ((eq mode 'open) + (shell-command "/usr/bin/open .")) + ) + + )) ;; Open Terminal.app @@ -243,13 +278,17 @@ (do-applescript (format " tell application \"Terminal\" - activate try + %s do script with command \"cd %s\" on error beep end try -end tell" dir)) +end tell" dir +(if mac-key-use-smartactivate-osax + "ActivateProcess identifier \"com.apple.Terminal\"" + "activate") +)) ))