MacOSX WorkShop/dot emacs el

提供: OSXWS Wiki
2021年5月4日 (火) 08:35時点におけるTkoba (トーク | 投稿記録)による版 (ページの作成:「MacOSX_WorkShop の「OSX-Preferences」と「emacs-lisps」で提供されている Emacs の設定ファイルを議論します。 == 基本方針 == *VineLinux…」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

MacOSX_WorkShop の「OSX-Preferences」と「emacs-lisps」で提供されている Emacs の設定ファイルを議論します。

基本方針

OSXWS は大学や研究機関の計算機管理者が導入し、管理者権限を持たない学生さんやユーザーが利用する事を念頭に置いて下さい。

  • 変更事項はその理由を明記する。

複数人の趣味に偏るのを避ける為にも必要です。

  • 修正案の作り方

このWiki上で修正案を作る方法として、取り除くほうが良いと考えている物を「(取り除いた項目)」に移し、追加したいと考えているものを実際に追加し「(追加した項目)」に記入するようにしています。それにコメント、指摘を書き込んで頂けたら助かります。

  • inline-patch や transparency patch 等 upstream で仕様が今後も変更される確率が高く、且つ、OSXWS としてのデフォルトなど基本的な設定は、site-start.d 内で行う。

OSXWS-10.11-1 の変更点

  • OSXWS-10.9-1 からの変更はありません。

OSXWS-10.11-x の emacs 設定ファイル

ユーザーの初期設定ファイルを読む直前に osxws.el がロードされる:"/osx/osxws/share/emacs/site-lisp/emacs-lisps/osxws.el"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  osxws.el for MacOS X WorkShop
;;            KOBAYASHI Taizo <xxxxxxx@xxxxxxx>
;; Time-stamp: 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; setting the MacOS X WorkShop flag
(defconst osxws-emacs-flag t 
  "This is Emacs of MacOS X WorkShop.")

(setq emacs-build-system 
      (concat 
       emacs-build-system
       " - MacOS X WorkShop - 10.11 "))

(setq report-emacs-bug-address "osxws@xxxxxxxxxxxx")

(defcustom osxws-default t
  "A boolean for all OSX Workshop default settings"
  :type 'boolean)

(defcustom osxws-default-base t
  "A boolean for loading osxws-setting section 0 (fundamental configurations)"
  :type 'boolean)

(defcustom osxws-default-language-auto t
  "A boolean for loading osxws-setting section 1 (language auto detect)"
  :type 'boolean)

(defcustom osxws-default-appearance t
  "A boolean for loading osxws-setting section 2 (appearance)"
  :type 'boolean)

(defcustom osxws-default-keyboard t
  "A boolean for loading osxws-setting section 3 (keyboard/keybinding)"
  :type 'boolean)

(defcustom osxws-default-shell t
  "A boolean for loading osxws-setting section 4 (shell-command)"
  :type 'boolean)

(defcustom osxws-default-inlinepatch t
  "A boolean for loading osxws-setting section 5 (inline patch)"
  :type 'boolean)

(defcustom osxws-default-cocoaemacs t
  "A boolean for loading osxws-setting section 6 (Cocoa Emacs)"
  :type 'boolean)

(defcustom osxws-default-else t
  "A boolean for loading osxws-setting section 7 (anything else)"
  :type 'boolean)

(defcustom osxws-default-mew t
  "A boolean for loading osxws-setting for Mew"
  :type 'boolean)

(defcustom osxws-default-yatex t
  "A boolean for loading osxws-setting for YaTeX"
  :type 'boolean)

(if (file-exists-p (concat user-emacs-directory "setup_osxws_default.el"))
    (load-file (concat user-emacs-directory "setup_osxws_default.el")))

(when osxws-default
    (message "Starting osxws-default ...")
    (load-file "/opt/osxws/share/emacs/site-lisp/emacs-lisps/osxws-default.el")
    (if osxws-default-yatex
        (load-file "/opt/osxws/share/emacs/site-lisp/emacs-lisps/osxws-default-yatex.el")
    )
  )

(setq custom-file "~/.emacs.d/custom_osxws.el")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local Variables:
;; mode: emacs-lisp
;; buffer-file-coding-system: junet-unix
;; End:

デフォルト設定を使用しない場合、ホームディレクトリのファイルから各変数を nil にする:"~/.emacs.d/setup_osxws_default.el"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ~/.emacs.d/setup_osxws_default.el
;;  .emacs for MacOS X WorkShop
;; Time-stamp: 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MacOS X WorkShop provides the default setting for Emacs.
;; The setting is written in the following file:
;; /opt/osxws/share/emacs/site-lisp/emacs-lisps/osxws-default.el
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; You can inactivate all by setting the variable osxws-defaul to nil.
;; (setq osxws-default nil)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; You can inactivate each section of the setting by setting
;; the variables osxws-defaul-* to nil.
;;(setq osxws-default-base nil)
;;(setq osxws-default-language-auto nil)
;;(setq osxws-default-appearance nil)
;;(setq osxws-default-keyboard nil)
;;(setq osxws-default-shell nil)
;;(setq osxws-default-inlinepatch nil)
;;(setq osxws-default-cocoaemacs  nil)
;;(setq osxws-default-else nil)
;;(setq osxws-default-mew nil)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; You can inactivate the default setting for YaTeX by
;;(setq osxws-default-yatex nil)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local Variables:
;; mode: emacs-lisp
;; buffer-file-coding-system: utf-8-unix
;; End:

init.el の例を兼ねて、最も変更する可能性の高いウィンドウ設定のみ記述:"~/.emacs.d/init.el"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ~/.emacs.d/init.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; You can edit this file as you like!
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; no start up message
;;(setq inhibit-startup-screen t)

;; window mode setting
(when (eq window-system 'ns)
  ;; window size
  ;;(setq default-frame-alist
  ;;   (append
  ;;     '((width . 100) (height . 40))
  ;;      default-frame-alist))
  ;; Color-thema
  (require 'color-theme)
  (color-theme-dark-blue2)

  ;; Transparency3
  (add-to-list
   'default-frame-alist
   '(alpha . (100 80))) ;; (alpha . (<active frame> <non active frame>))

  ;; Save GUI Emacs frame size and position. 
  ;; Restore the size and position when you launch Emacs.
  (require 'save-frame-posize)
  )

;; input special and control characters by "Option"
(setq ns-option-modifier 'none)

;; cursor mode
(setq blink-cursor-interval 0.5)
(setq blink-cursor-delay 5.0)
(blink-cursor-mode 1)   <--- 点滅を止める時は -1 に設定

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local Variables:
;; mode: emacs-lisp
;; buffer-file-coding-system: utf-8-unix
;; End:

デフォルト設定のファイル:"/opt/osxws/share/emacs/site-lisp/emacs-lisps/osxws-default.el"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; osxws-default.el for MacOS X WorkShop
;; Time-stamp:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 0 fundamental configurations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-base 
  ;;;; path setting
  (setq exec-path
	(append
	 (list "/opt/osxws/bin" "~/bin") exec-path))
  (setenv "PATH" 
	  (concat '"/opt/osxws/bin:~/bin:" (getenv "PATH")))
  
  ;;; save the position before you editing.
  (require 'saveplace)
  (setq-default save-place t)
  (setq save-place-file "~/Library/Application Support/OSXWS/emacs-places.txt")
  
  ;;; copy foo to foo~ as a backup file
  (setq backup-by-copying t)

  ;;; yank text with mouse
  (setq mouse-drag-copy-region t)

  ;;; deleting files goes to OS's trash folder
  ;;(setq delete-by-moving-to-trash t)
  ;;(setq trash-directory "~/.Trash")

  ;;; start emacsclient server if in window mode
  (if window-system
      (progn
        (require 'server)
        (unless (server-running-p) (server-start))))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 1 language configurations (auto detect)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq appleLang
      (shell-command-to-string 
        "/bin/echo -n `/usr/bin/defaults read -g AppleLocale | cut -f 1 -d _`"))

(when osxws-default-language-auto
  ;;; japanese settings for Cocoa Emacs
  (cond ((string-match appleLang "ja") (set-language-environment 'Japanese))
        ((string-match appleLang "en") (set-language-environment 'English))
        ((string-match appleLang "fr") (set-language-environment 'French))
        ((string-match appleLang "de") (set-language-environment 'German))
        ((string-match appleLang "es") (set-language-environment 'Spanish))
        ((string-match appleLang "it") (set-language-environment 'Italian))
        ((string-match appleLang "nl") (set-language-environment 'Dutch))
        ((string-match appleLang "sv") (set-language-environment 'Swedish))
        (t (set-language-environment 'English)))
  (prefer-coding-system  'utf-8-unix)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 2 appearance setting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-appearance
  ;;; hide tool-bar and menu-bar
  (if window-system
      (tool-bar-mode 0)
    (menu-bar-mode 0))
  
  ;;; show the corresponding paren 
  (show-paren-mode)
  
  ;;; do not font scaling
  (setq scalable-fonts-allowed nil)
  
  ;;; show the present time on status bar
  (when (equal current-language-environment "Japanese")
    (setq dayname-j-alist
	  '(("Sun" . "日") ("Mon" . "月")
	    ("Tue" . "火") ("Wed" . "水")
	    ("Thu" . "木") ("Fri" . "金")
	    ("Sat" . "土")))
    (setq display-time-string-forms
	  '((format "%s年%s月%s日(%s) %s:%s %s"
		    year month day
		    (cdr (assoc dayname dayname-j-alist))
		    24-hours minutes
		    load))))
  (display-time)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 3 keyboard/keybinding
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-keyboard
  ;;; emulation of the standard CUA key bindings (Mac GUI)
  (cua-selection-mode t)
  
  ;;; behavior of "Command + Cursor" to the default of MacOS X
  ;;; default : ns-next-frame in ns-win.el
  (define-key global-map [s-left] 'move-beginning-of-line)
  ;;; default : ns-prev-frame in ns-win.el
  (define-key global-map [s-right] 'move-end-of-line)
  (define-key global-map [s-up] 'backward-page)
  (define-key global-map [s-down] 'forward-page)
  
  ;;; font resize short cut (Command +/-/0)
  (global-set-key [(s ?+)] (lambda () (interactive) (text-scale-increase 1)))
  (global-set-key [(s ?-)] (lambda () (interactive) (text-scale-decrease 1)))
  (global-set-key [(s ?0)] (lambda () (interactive) (text-scale-increase 0)))
  
  ;;; revert [Home] Key and [End] Key
  (define-key global-map [home] 'beginning-of-buffer)
  (define-key global-map [end] 'end-of-buffer)

  ;;; Delete the following character by fn + delete 
  (define-key global-map [kp-delete] 'delete-char)
  
  ;;; fix yen key problem on JIS keyboard
  ;;; Ando-san's code (see [Macemacsjp-users 1126])
  (define-key global-map [2213] nil)
  (define-key global-map [67111077] nil)
  (define-key function-key-map [2213] [?\\])
  (define-key function-key-map [67111077] [?\C-\\]) 
  
  (define-key global-map [3420] nil)
  (define-key global-map [67112284] nil)
  (define-key function-key-map [3420] [?\\])
  (define-key function-key-map [67112284] [?\C-\\])
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 4 shell-command
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-shell
  ;;; hide password 
  (add-hook 'comint-output-filter-functions
	    'comint-watch-for-password-prompt)
  
  ;;; escape sequence
  (autoload 'ansi-color-for-comint-mode-on "ansi-color"
    "Set `ansi-color-for-comint-mode' to t." t)
  (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 5 inline-patch by Hashimoto-san
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-inlinepatch
  (when window-system
    (setq default-input-method "MacOSX")
    (add-hook 'minibuffer-setup-hook 'mac-change-language-to-us)
    ;;(mac-add-ignore-shortcut '(control))
    (mac-add-key-passed-to-system 'shift)
    (mac-set-input-method-parameter "com.apple.inputmethod.Kotoeri.Roman" `title "あ")
    (mac-set-input-method-parameter "com.apple.inputmethod.Kotoeri.Roman" `cursor-type 'box)
    (mac-set-input-method-parameter "com.apple.inputmethod.Kotoeri.Japanese" `cursor-color "red"))
  
  ;;; start up by Command-Space
  (global-set-key [(s \ )] 'toggle-input-method)
  ;;; start up by Shift-Space
  (global-set-key [?\S-\ ] 'toggle-input-method)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 6 CocoaEmacs window mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-cocoaemacs
  (when window-system
    ;;;; Font setting
    (set-frame-font "Inconsolata 16")
    (set-fontset-font (frame-parameter nil 'font)
		      'unicode
		      '("ヒラギノ丸ゴ ProN" . "unicode-bmp") nil 'append)
    (add-to-list 'default-frame-alist '(font . "Inconsolata 16"))
    
    ;;;; smart-dnd
    (require 'smart-dnd)
    
    ;;; yahtml-mode:
    (add-hook
     'yahtml-mode-hook
     '(lambda ()
	(smart-dnd-setup
	 '(
	   ("\\.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")))))
    
    ;;; yatex-mode:
    (add-hook
     'yatex-mode-hook
     '(lambda ()
	(smart-dnd-setup
	 '(
	   ("\\.tex\\'" . "\\input{%r}\n")
	   ("\\.cls\\'" . "\\documentclass{%f}\n")
	   ("\\.sty\\'" . "\\usepackage{%f}\n")
	   ("\\.eps\\'" . "\\includegraphics[clip]{%r}\n")
	   ("\\.ps\\'"  . "\\includegraphics[clip]{%r}\n")
	   ("\\.pdf\\'" . "\\includegraphics[clip]{%r}\n")
	   ("\\.jpg\\'" . "\\includegraphics[clip]{%r}\n")
	   ("\\.png\\'" . "\\includegraphics[clip]{%r}\n")
	   ("\\.bst\\'" . "\\bibliographystyle{%n}\n")
	   ("\\.bib\\'" . "\\bibliography{%n}\n")))))
    
    ;;; C/C++ mode:
    (add-hook 
     'c-mode-common-hook
     '(lambda () (smart-dnd-setup '(("\\.h\\'" . "#include <%f>")))))
    )
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Section 7 anything else
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-else
  ;;; The number of lines to scroll a window by when point moves out.
  (setq scroll-step 1)
  
  ;;;; Time Stamp
  ;;;   If you put 'Time-stamp: <>' or 'Time-stamp: ""' on
  ;;;   top 8 lines of the file, the '<>' or '""' are filled with the date
  ;;;   at saving the file.
  (require 'time-stamp)
  (if (not (memq 'time-stamp write-file-functions))
      (setq write-file-functions
	    (cons 'time-stamp write-file-functions)))

  ;;;; Auto Complete Mode
  (require 'auto-complete-config)
  (ac-config-default)
  (add-to-list 'ac-dictionary-directories "/opt/osxws/share/emacs/site-lisp/emacs-lisps/ac-dict")
  
  ;;; text-to-speech by say: sentence
  (defun osxws-speech (b e)
    "Convert text to audible speech by /usr/bin/say of OSX."
    (interactive "r")
    (let (str)
      (if (eq mark-active 'nil)
          (progn (setq b1 (save-excursion (re-search-backward "^\\ *%")
                                          (point)))
                 (setq b2 (save-excursion (re-search-backward "^\n")
                                          (point)))
                 (setq e1 (save-excursion (re-search-forward "^\\ *%")
                                          (point)))
                 (setq e2 (save-excursion (re-search-forward "^\n")
                                          (point)))
                 (setq b (if (< b1 b2) b2 t b1))
                 (setq e (if (> e1 e2) e2 t e1))))
      (setq str (buffer-substring-no-properties b e))
      (setq str (replace-regexp-in-string "\\\\%" "percent" str))
      (setq str (replace-regexp-in-string "%[^\n]*" "" str))
      (setq str (replace-regexp-in-string "\\\\[a-zA-Z]+{" " " str))
      (setq str (replace-regexp-in-string "[$_^\n()~{}|;`]" " " str))
      (setq str (replace-regexp-in-string "\\ +" " " str))
      (message str)
      (if (eq (process-status "speech") 'run)
          (delete-process "speech")
        (process-kill-without-query
         (start-process-shell-command "speech" nil 
                                      "/usr/bin/say " (concat "\"" str "\"" ))))))

  ;;; text-to-speech by say: word
  (defun osxws-speech-word()
    "Speak words."
    (interactive)
    (let* ((str (url-hexify-string (string-word-or-region))))
      (process-kill-without-query
       (start-process-shell-command "speech" nil 
                                    "/usr/bin/say -r 150" (concat "\"" str "\"" )))))
  
  ;;; Search marked region by google
  (defun osxws-search-google()
    "Search marked region by google"
    (interactive)
    (let* ((str (string-word-or-region)))
      (browse-url
       (concat "http://google.com/search?q=\"" str "\""))))

  ;;; Search marked region by google scholar
  (defun osxws-search-googlescholar()
    "Search string by google scholar"
    (interactive)
    (let* ((str (string-word-or-region)))
      (browse-url
       (concat "http://scholar.google.com/scholar?q=\"" str "\""))))
  
  ;;; "Look up the word by Dictionary.app of Mac OS X"
  ;;; http://sakito.jp/mac/dictionary.html
  (defun osxws-lookup-dictionary-osx()
    "Look up the word by Dictionary.app of Mac OS X"
    (interactive)
    (let* ((str (url-hexify-string (string-word-or-region))))
      (browse-url (concat "dict://" str ))))

  (defun string-word-or-region ()
    "If a region is selected, the text string of the region is returned.
  Otherwise, the text string of the word is returnd."
    (let ((editable (not buffer-read-only))
          (pt (save-excursion (mouse-set-point last-nonmenu-event)))
          beg end)
      (if (and mark-active
               (<= (region-beginning) pt) (<= pt (region-end)) )
          (setq beg (region-beginning)
                end (region-end))
        (save-excursion
          (goto-char pt)
          (backward-char 1)
          (setq end (progn (forward-word) (point)))
          (setq beg (progn (backward-word) (point)))))
      (buffer-substring-no-properties beg end)))


  ;;; Show in Finder
  (defun osxws-show-in-finder ()
    (interactive)
    (process-kill-without-query
     (start-process-shell-command "Show in Finder" nil "open -R" (buffer-file-name))))

  ;;; Open current working directory by Finder
  (defun osxws-open-folder-in-finder ()
    "open -a Finder.app CURRENT-DIRECTORY"
    (interactive)
    (process-query-on-exit-flag 
     (start-process-shell-command "open folder in Finder" nil "open .")))

  ;;; Open current working directory by Terminal/iTerm
  (defun osxws-open-Terminal()
    "open -a Terminal.app CURRENT-DIRECTORY"
    (interactive)
    (let* (;;(cmd "open -a Terminal.app")
           (cmd "open -a iTerm.app"))
      (process-kill-without-query
       (start-process-shell-command 
        "Open directory" nil cmd default-directory))))
  
  ;;; keybindings
  (define-key global-map [?\s-r] 'osxws-speech)
  ;; keybinding: ⌘-option-r
  (define-key global-map [?\s-®] 'osxws-speech-word)
  ;; keybinding: ⌘-option-shift-F
  (define-key global-map [?\s-Ï] 'osxws-open-folder-in-finder)
  ;; keybinding: ⌘-option-shift-T
  (define-key global-map [?\s-ˇ] 'osxws-open-Terminal)

  (define-key global-map (kbd "C-;") 'ispell-word)
  (define-key global-map (kbd "C-c w") 'osxws-lookup-dictionary-osx)
  (define-key global-map (kbd "C-c g") 'osxws-search-google)
  (define-key global-map (kbd "C-c G") 'osxws-search-googlescholar)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Mew 6.6  -  Messaging in the Emacs World
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(when osxws-default-mew
  (autoload 'mew "mew" nil t)
  (autoload 'mew-send "mew" nil t)
  (if (file-exists-p "~/.emacs.d/mew.el")
        (load-file "~/.emacs.d/mew.el"))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local Variables:
;; mode: emacs-lisp
;; buffer-file-coding-system: utf-8-unix
;; End:

YaTeX のデフォルト設定:"/opt/osxws/share/emacs/site-lisp/emacs-lisps/osxws-default-yatex.el"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; osxws-default-yatex.el for MacOS X WorkShop
;; Time-stamp:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

;; use \C-c \C- instead of \C-c [yatex:04567]
(unless (boundp 'YaTeX-inhibit-prefix-letter)
      (setq YaTeX-inhibit-prefix-letter t))

;; use our own scripts for typesetting
(setq YaTeX-typeset-auto-rerun nil)

(setq auto-mode-alist
      (append
	'(("\\.\\(tex\\|sty\\|cls\\|fd\\|ind\\|idx\\|ltx\\|clo\\|bbl\\)$" .
	   yatex-mode)) auto-mode-alist))

(setq YaTeX-latex-message-code 'utf-8
      YaTeX-use-LaTeX2e t ; AMS-LaTeX
      YaTeX-use-AMS-LaTeX t ; AMS-LaTeX
      YaTeX-use-font-lock t
      YaTeX-skip-default-reader  t)

(if (equal current-language-environment "Japanese")
  (setq YaTeX-kanji-code nil ; (1 JIS, 2 SJIS, 3 EUC, 4 UTF-8)
        tex-command "platex2pdf"
        dvi2-command "open -a Skim"
        makeindex-command "mendex2pdf"
        bibtex-command "pbibtex2pdf"
        dviprint-command-format "dvipdfmx %s -o - | lpr")
  (setq YaTeX-kanji-code nil ; (1 JIS, 2 SJIS, 3 EUC, 4 UTF-8)
        tex-command "latex2pdf"
        dvi2-command "open -a Skim"
        makeindex-command "makeindex2pdf"
        bibtex-command "bibtex2pdf"
        dviprint-command-format "dvipdfmx %s -o - | lpr")
  )


(add-hook 'skk-mode-hook
	  (lambda ()
	    (if (eq major-mode 'yatex-mode)
	      (progn
		(define-key skk-j-mode-map "\\" 'self-insert-command)
		(define-key skk-j-mode-map "$" 'YaTeX-insert-dollar)
		))
))

;;; Indent
;;; http://www.hit.ac.jp/~wachi/misc/latexindent.html
(autoload 'latex-indent-command "latex-indent"
	  "Indent current line accroding to LaTeX block structure.")
(autoload 'latex-indent-region-command "latex-indent"
	  "Indent each line in the region according to LaTeX block structure.")

;;;; Skim PDF indicating cursor
;;; pdflatex/platex -synctex=1 
;;; switch from Emacs to Skim: C-c s
(defun skim-forward-search ()
  (interactive)
  (process-kill-without-query
    (start-process
      "displayline"
      nil
      "/Applications/OSXWS/Skim.app/Contents/SharedSupport/displayline"
      (number-to-string (save-restriction
                          (widen)
                          (count-lines (point-min) (point))))
      (expand-file-name
        (concat (file-name-sans-extension (or YaTeX-parent-file
                                              (save-excursion
                                                (YaTeX-visit-main t)
                                                buffer-file-name)))
                ".pdf"))
      buffer-file-name)))

;;; insert subscript with roman font
(defun osxws-TeX-insert-subscript_rm ()
  "insert subscript with roman font"
  (interactive)
  (insert "_{\\mathrm{}}")
  (backward-char 2))

;;; switch to previous buffer
(defun osxws-TeX-switch-to-previousbuffer ()
  "switch to previous buffer"
  (interactive)
  (switch-to-buffer nil))

;;; Open BibDesk with the cite key
(defun osxws-TeX-open-item-BibDesk ()
  "Open BibDesk with the cite key"
  (interactive)
  (let* ((s (save-excursion
              (skip-chars-backward "^{,")
              (point)))
         (e (save-excursion
              (skip-chars-forward "^},")
              (point))))
    (browse-url (concat "x-bdsk://" (buffer-substring-no-properties s e)))))

;;; Open BibDesk
(defun osxws-open-bibdesk ()
  "Open BibDesk"
  (interactive)
  (process-kill-without-query
   (start-process-shell-command "Open BibDesk.app" nil "open -a BibDesk" )))

;;; \cite{foo} -> open foo.pdf
;;; citekey == PDF file name
(defun osxws-TeX-open-article ()
  "Open PDF file by the cite key: \cite{foo} -> open foo.pdf"
  (interactive)
  (let* ((s (save-excursion
              (skip-chars-backward "^{,")
              (point)))
         (e (save-excursion
              (skip-chars-forward "^},")
              (point)))
        ;(pdfdir "~/Documents/Dropbox/Papers/pdf/")
         (pdfdir (interactive "DPDF file directory name: "))
         (pdffile (concat pdfdir
                          (buffer-substring-no-properties s e) ".pdf"))
         (process-kill-without-query
          (start-process-shell-command "Open the article" nil "open" pdffile)))))

;;; Convert text to audible speech by /usr/bin/say (Emacs + OSX) 
(defun osxws-TeX-speech ()
  "Convert text to audible speech by /usr/bin/say of OSX."
  (interactive)
  (let (b e s
          (block-sep-str "^\*\\|^\\ *%\\|^\\ *\n\\|\\\\item\\|\\\\begin\\|\\\\end"))
    (if (eq (process-status "speech") 'run)
        (delete-process "speech")
      (progn
        (if mark-active
            (setq b (mark) e (point))
          (setq b (save-excursion
                    (progn
                      (re-search-backward block-sep-str (point-min) 1)
                      (point)))
                e (save-excursion
                    (progn
                      (re-search-forward block-sep-str (point-max) 1)
                      (point)))))
        (setq s (buffer-substring-no-properties b e)
              s (replace-regexp-in-string "\\\\%" "percent" s)
              s (replace-regexp-in-string "$\\\\mu$m" "micrometer" s)
              s (replace-regexp-in-string "\\\\item" " " s)
              s (replace-regexp-in-string "\\\\begin" " " s)
              s (replace-regexp-in-string "\\\\end" " " s)
              s (replace-regexp-in-string "\\\\," " " s)
              s (replace-regexp-in-string "%[^\n]*" "" s)
              s (replace-regexp-in-string 
                 "\\\\[a-zA-Z]+{\\|[$\\\\_^~{}`\"*\n]" " " s)
              s (replace-regexp-in-string "\\ +" " " s))
        (message s)
        (process-kill-without-query
         (start-process-shell-command "speech" nil
                                      "/usr/bin/say" (concat "\"" s "\"" )))))))


;;; YaTeX key bindings
(add-hook 'yatex-mode-hook
          '(lambda ()
             (require 'yatexprc)
             (turn-off-auto-fill) ; no auto fill
             (define-key YaTeX-mode-map [?\s-t]
               (lambda ()
                 (interactive)
                 (YaTeX-typeset-menu nil ?j)))
             (define-key YaTeX-mode-map [?\s-b]
               (lambda ()
                 (interactive)
                 (YaTeX-typeset-menu nil ?j)))
             (define-key YaTeX-mode-map [?\s-P]
               (lambda (arg)
                 (interactive "P")
                 (let ((current-prefix-arg (not arg)))
                   (YaTeX-typeset-menu 'dummy ?p))))
             (define-key YaTeX-mode-map [?\s-B]
               (lambda ()
                 (interactive)
                 (YaTeX-typeset-menu nil ?b)))
             (define-key YaTeX-mode-map [?\s-I]
               (lambda ()
                 (interactive)
                 (YaTeX-typeset-menu nil ?i)))
             (define-key YaTeX-mode-map [?\s-J] 'osxws-TeX-open-item-BibDesk)
             (define-key YaTeX-mode-map [?\s-R] 'skim-forward-search)
             (define-key YaTeX-mode-map (kbd "C-c s") 'skim-forward-search)
             (define-key YaTeX-mode-map "\t" 'latex-indent-command)
             (define-key YaTeX-mode-map (kbd "C-c TAB") 'latex-indent-region-command)
             (define-key YaTeX-mode-map [?\s-_] 'osxws-TeX-insert-subscript_rm)
             (define-key YaTeX-mode-map [?\C-\s-J] 'YaTeX-goto-corresponding-*)
             (define-key YaTeX-mode-map [?\s-H] 'YaTeX-display-hierarchy)
             (define-key YaTeX-mode-map [?\s-1] 'YaTeX-visit-main)
             (define-key YaTeX-mode-map [?\s-2] 'osxws-TeX-switch-to-previousbuffer)
             (define-key YaTeX-mode-map [?\M-\s-B] 'osxws-open-bibdesk)
             (define-key YaTeX-mode-map [?\s-ı] 'osxws-open-bibdesk)
             (define-key YaTeX-mode-map [?\s-\)] 'osxws-TeX-speech-region)
             (define-key YaTeX-mode-map [?\s-C] 'osxws-TeX-open-article)
             ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; yahtml 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq auto-mode-alist
      (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist))
(autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t)
(add-to-list 'auto-mode-alist '("\\.htm\\'" . yahtml-mode))

(setq yahtml-www-browser "open"
      yahtml-lint-program "htmllint"
      yahtml-kanji-code 4)
 
(add-hook 'yahtml-mode-hook
     '(lambda ()
       (auto-fill-mode -1)
       )) 

;;;; <p> </p>
(setq yahtml-always-/p t)
;;;; <li> </li>
(setq yahtml-always-/li t)

;; End:

コメント

<comments />

10.10 Yosemite 版に関する議論

ありませんでした。

10.9 Maverics 版に関する議論

ありませんでした。

10.8 MountainLion 版に関する議論

ありませんでした。

10.7 Lion 版に関する議論

http://www.bach-phys.ritsumei.ac.jp/OSXWS/Lion/node56.html

10.6 SnowLeopard 版に関する議論

http://www.bach-phys.ritsumei.ac.jp/OSXWS/SnowLeopard/node59.html

10.5 Leopard 版に関する議論

http://www.bach-phys.ritsumei.ac.jp/OSXWS/Leopard/node59.html

10.4 Tiger 版に関する議論

http://www.bach-phys.ritsumei.ac.jp/OSXWS/Tiger/node60.html


参考したサイト