Skip to content

Instantly share code, notes, and snippets.

View ryseto's full-sized avatar

Ryohei Seto ryseto

View GitHub Profile
(defun MyTool-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 "\"" )))))
(defun string-word-or-region ()
"If a region is selected, the text string of the region is returned.
#!/bin/bash
#
# You need to put the following in ~/.emacs.d/init.el.
# (if window-system
# (progn
# (require 'server)
# (unless (server-running-p) (server-start))))
#
EMACS_PID_ALL=`pgrep -d ' ' Emacs`
EMACS_ACTIVE=0
@ryseto
ryseto / latexdiff_dropbox.sh
Last active August 29, 2015 14:09
latexdiff_dropbox.sh
#!/bin/sh
my_typesetter="latexmk"
my_latexdiff="latexdiff"
orig_file=`basename $1 .tex`
if [ ! -f $orig_file.tex ]; then
echo "PDF file is not found."
exit
fi
echo "Input the version:"
@ryseto
ryseto / gist:2242924
Created March 29, 2012 19:44
Run 'say' command on Emacs
;;; Convert text to audible speech by /usr/bin/say (Emacs + OSX)
(defun MyTeX-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
@ryseto
ryseto / gist:2243572
Created March 29, 2012 20:39
Open PDF file by the cite key: \cite{foo} -> open foo.pdf
(defun MyTeX-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/")
@ryseto
ryseto / gist:2259918
Created March 31, 2012 06:19
Font setting for Emacs23 (Cocoa Emacs) create-fontset
;;; フォントセットを作る
(let* ((fontset-name "myfonts") ; フォントセットの名前
(size 12) ; ASCIIフォントのサイズ [9/10/12/14/15/17/19/20/...]
(asciifont "Menlo") ; ASCIIフォント
(jpfont "Hiragino Maru Gothic ProN") ; 日本語フォント
(font (format "%s-%d:weight=normal:slant=normal" asciifont size))
(fontspec (font-spec :family asciifont))
(jp-fontspec (font-spec :family jpfont))
(fsn (create-fontset-from-ascii-font font nil fontset-name)))
(set-fontset-font fsn 'japanese-jisx0213.2004-1 jp-fontspec)
@ryseto
ryseto / gist:2259928
Created March 31, 2012 06:21
Font setting for Emacs23 (Cocoa Emacs) set-face-attribute
;;; フレームのフォントを設定
(let* ((size 12) ; ASCIIフォントのサイズ [9/10/12/14/15/17/19/20/...]
(asciifont "Menlo") ; ASCIIフォント
(jpfont "Hiragino Maru Gothic ProN") ; 日本語フォント
(h (* size 10))
(fontspec (font-spec :family asciifont))
(jp-fontspec (font-spec :family jpfont)))
(set-face-attribute 'default nil :family asciifont :height h)
(set-fontset-font nil 'japanese-jisx0213.2004-1 jp-fontspec)
(set-fontset-font nil 'japanese-jisx0213-2 jp-fontspec)
@ryseto
ryseto / gist:2260412
Created March 31, 2012 07:26
Speaking a selected region in Japanese (Emacs+OSX)
(defun MyTool-speech-region-Kyoko ()
"Convert text to audible speech by /usr/bin/say of OSX."
(interactive)
(let ((str (concat (buffer-substring-no-properties (point) (mark)))))
(setq str (replace-regexp-in-string "\\\\%" "percent" str))
(setq str (replace-regexp-in-string "%\n" "" str))
(setq str (replace-regexp-in-string "\\%[^\n]+" "" str))
(setq str (replace-regexp-in-string "%" "" str))
(setq str (replace-regexp-in-string "\\\\[a-zA-Z]+" " " str))
(setq str (replace-regexp-in-string "[$_^\n()~{}|;]" " " str))
@ryseto
ryseto / jor_template.tex
Created June 11, 2014 02:47
Templete for Journal of Rheology
\documentclass[
aip,
author-year,
reprint,
onecolumn,
tightenlines,
12pt,
notitlepage,
amsmath,
amssymb
(define-key global-map (kbd "C-c w") 'MyTool-lookup-dictionary-osx)
(define-key global-map (kbd "C-c g") 'MyTool-search-google)
(define-key global-map (kbd "C-c G") 'MyTool-search-googlescholar)
(defun MyTool-search-google()
"Search by google"
(interactive)
(let* ((str (string-word-or-region)))
(browse-url
(concat "http://google.com/search?q=\"" str "\""))))