Browse Source

Merge branch 'master' of github.com:10sr/myrcfiles

pull/1/head
10sr 12 years ago
parent
commit
b9403dfd79
2 changed files with 103 additions and 94 deletions
  1. +3
    -0
      .bashrc
  2. +100
    -94
      .emacs.el

+ 3
- 0
.bashrc View File

@@ -333,6 +333,9 @@ echo "Japanese letters are 表示可能"


safe-cmd diskinfo safe-cmd diskinfo


type xrandr >/dev/null 2>&1 && {
xrandr | grep --color=never ^Screen
}
safe-cmd finger $USER safe-cmd finger $USER
LANG=C safe-cmd id LANG=C safe-cmd id



+ 100
- 94
.emacs.el View File

@@ -232,9 +232,11 @@
(global-font-lock-mode 1) (global-font-lock-mode 1)


(standard-display-ascii ?\n "$\n") (standard-display-ascii ?\n "$\n")
(defface my-eol-face
'((t (:foreground "green")))
"eol.")
(copy-face 'default 'my-eol-face)
(set-face-foreground 'my-eol-face "green")
;; (defface my-eol-face
;; '((t (:foreground "green")))
;; "eol.")


(standard-display-ascii ?\f "---------------------------------------------------------------------------------------^L") (standard-display-ascii ?\f "---------------------------------------------------------------------------------------^L")
(defface my-pagebreak-face (defface my-pagebreak-face
@@ -242,7 +244,8 @@
"pagebreak.") "pagebreak.")


(defvar my-eol-face (defvar my-eol-face
'(("\n" . '(0 my-eol-face t nil))))
'(("\n" . (0 my-eol-face t nil)))
)
(defvar my-pagebreak-face (defvar my-pagebreak-face
'(("\f" . 'my-pagebreak-face))) '(("\f" . 'my-pagebreak-face)))
(defvar my-highlight-face (defvar my-highlight-face
@@ -287,8 +290,9 @@


(add-hook 'font-lock-mode-hook (add-hook 'font-lock-mode-hook
(lambda () (lambda ()
(font-lock-add-keywords nil my-eol-face)
(font-lock-add-keywords nil my-highlight-face)))
;; (font-lock-add-keywords nil my-eol-face)
;; (font-lock-add-keywords nil my-highlight-face)
))


(set-face-foreground 'font-lock-regexp-grouping-backslash "#666") (set-face-foreground 'font-lock-regexp-grouping-backslash "#666")
(set-face-foreground 'font-lock-regexp-grouping-construct "#f60") (set-face-foreground 'font-lock-regexp-grouping-construct "#f60")
@@ -352,9 +356,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mode-line ;; mode-line


(setq eol-mnemonic-dos "(CRLF)")
(setq eol-mnemonic-mac "(CR)")
(setq eol-mnemonic-unix "(LF)")
(setq eol-mnemonic-dos "CL")
(setq eol-mnemonic-mac "CR")
(setq eol-mnemonic-unix "LF")


(which-function-mode 0) (which-function-mode 0)


@@ -414,7 +418,7 @@
(setq backup-directory-alist (setq backup-directory-alist
(cons (cons "\\.*$" (expand-file-name "~/.emacs.d/backup")) (cons (cons "\\.*$" (expand-file-name "~/.emacs.d/backup"))
backup-directory-alist)) backup-directory-alist))
(setq version-control t)
(setq version-control 'never)
(setq delete-old-versions t) (setq delete-old-versions t)


(setq auto-save-list-file-prefix (expand-file-name "~/.emacs.d/autosave/")) (setq auto-save-list-file-prefix (expand-file-name "~/.emacs.d/autosave/"))
@@ -438,11 +442,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; buffer killing ;; buffer killing


;; (add-hook 'kill-buffer-hook
;; (lambda ()
;; (when buffer-file-name
;; (dired "."))))

(defun kill-buffer-by-major-mode (mode &optional exclude-current-buffer-p) ;mapcarとかつかって全部書き換える (defun kill-buffer-by-major-mode (mode &optional exclude-current-buffer-p) ;mapcarとかつかって全部書き換える
"kill buffers. "kill buffers.
if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer" if EXCLUDE-CURRENT-BUFFER-P is non-nil, never kill current buffer"
@@ -755,6 +754,13 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB."
(when (require 'gtkbm nil t) (when (require 'gtkbm nil t)
(global-set-key (kbd "C-x C-d") 'gtkbm)) (global-set-key (kbd "C-x C-d") 'gtkbm))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; frame buffer

;; (add-hook 'after-make-frame-functions
;; (lambda (frame)
;; (recentf-open-files)))

(defvar my-frame-buffer-plist nil) (defvar my-frame-buffer-plist nil)
(setplist my-frame-buffer-plist nil) (setplist my-frame-buffer-plist nil)


@@ -781,6 +787,17 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB."
(or frame (or frame
(selected-frame)))) (selected-frame))))


(defun my-frame-buffer-get2 (&optional frame)
""
(delq nil (mapcar (lambda (buf)
(if (or t (buffer-file-name buf))
buf
nil))
(cdr (assq 'buffer-list
(frame-parameters (or frame
(selected-frame))))))))
(my-frame-buffer-get2)

(defun my-frame-buffer-kill-all-buffer (frame) (defun my-frame-buffer-kill-all-buffer (frame)
"" ""
(mapcar 'kill-buffer (mapcar 'kill-buffer
@@ -788,11 +805,17 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB."


(add-hook 'find-file-hook (add-hook 'find-file-hook
'my-frame-buffer-add) 'my-frame-buffer-add)
(add-hook 'dired-mode-hook
'my-frame-buffer-add)
(add-hook 'term-mode-hook
'my-frame-buffer-add)
(add-hook 'kill-buffer-hook (add-hook 'kill-buffer-hook
'my-frame-buffer-remove) 'my-frame-buffer-remove)
(add-hook 'delete-frame-functions (add-hook 'delete-frame-functions
'my-frame-buffer-kill-all-buffer) 'my-frame-buffer-kill-all-buffer)


(frame-parameters (selected-frame))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; term mode ;; term mode


@@ -800,7 +823,8 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB."
(and (dllib-if-unfound "multi-term" (and (dllib-if-unfound "multi-term"
"http://www.emacswiki.org/emacs/download/multi-term.el" "http://www.emacswiki.org/emacs/download/multi-term.el"
t) t)
(require 'multi-term nil t))
(require 'multi-term nil t)
(setq multi-term-switch-after-close nil))


;; http://d.hatena.ne.jp/goinger/20100416/1271399150 ;; http://d.hatena.ne.jp/goinger/20100416/1271399150
;; (setq term-ansi-default-program shell-file-name) ;; (setq term-ansi-default-program shell-file-name)
@@ -821,7 +845,7 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB."
(define-key term-raw-map [delete] 'term-send-raw) (define-key term-raw-map [delete] 'term-send-raw)
(define-key term-raw-map "\C-h" 'term-send-backspace) (define-key term-raw-map "\C-h" 'term-send-backspace)
(define-key term-raw-map "\C-y" 'term-paste) (define-key term-raw-map "\C-y" 'term-paste)
(define-key term-raw-map "\C-c" 'term-interrupt-subjob)
(define-key term-raw-map "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob)
;; (dolist (key '("<up>" "<down>" "<right>" "<left>")) ;; (dolist (key '("<up>" "<down>" "<right>" "<left>"))
;; (define-key term-raw-map (kbd key) 'term-send-raw)) ;; (define-key term-raw-map (kbd key) 'term-send-raw))
;; (define-key term-raw-map "\C-d" 'delete-char) ;; (define-key term-raw-map "\C-d" 'delete-char)
@@ -844,13 +868,16 @@ return nil if LIB unfound and downloading failed, otherwise the path of LIB."
;; (add-to-list 'bs-configurations '("processes" nil get-buffer-process ".*" nil nil)) ;; (add-to-list 'bs-configurations '("processes" nil get-buffer-process ".*" nil nil))
(add-to-list 'bs-configurations '("same-dir" nil buffer-same-dir-p ".*" nil nil)) (add-to-list 'bs-configurations '("same-dir" nil buffer-same-dir-p ".*" nil nil))
(add-to-list 'bs-configurations '("this-frame" nil (lambda (buf) (memq buf (my-frame-buffer-get))) ".*" nil nil)) (add-to-list 'bs-configurations '("this-frame" nil (lambda (buf) (memq buf (my-frame-buffer-get))) ".*" nil nil))
(add-to-list 'bs-configurations '("this-frame2" nil (lambda (buf) (memq buf (my-frame-buffer-get2))) ".*" nil nil))
;; (setq bs-configurations (list '("processes" nil get-buffer-process ".*" nil nil) ;; (setq bs-configurations (list '("processes" nil get-buffer-process ".*" nil nil)
;; '("files-and-scratch" "^\\*scratch\\*$" nil nil bs-visits-non-file bs-sort-buffer-interns-are-last))) ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil bs-visits-non-file bs-sort-buffer-interns-are-last)))
(setq bs-default-configuration "this-frame") (setq bs-default-configuration "this-frame")
(setq bs-default-sort-name "by name") (setq bs-default-sort-name "by name")
(add-hook 'bs-mode-hook (add-hook 'bs-mode-hook
(lambda () (lambda ()
(setq bs-default-configuration "this-frame")))
(setq bs-default-configuration "this-frame")
(set (make-variable-buffer-local 'scroll-margin) 0)
))


(defun buffer-same-dir-p (bf) (defun buffer-same-dir-p (bf)
"return t if BF's dir is same as current dir, otherwise nil." "return t if BF's dir is same as current dir, otherwise nil."
@@ -1099,26 +1126,31 @@ if arg is omitted use value of `buffer-list'."
(length infiles)) (length infiles))
(car infiles)))) (car infiles))))
(if (and onefile (if (and onefile
(assoc (file-name-extension onefile)
my-pack-program-alist))
(my-pack-file-name-association onefile))
(when (y-or-n-p (format "unpack %s? " onefile)) (when (y-or-n-p (format "unpack %s? " onefile))
(my-unpack onefile)
(revert-buffer))
(my-unpack onefile))
(let* ((dir-default (dired-dwim-target-directory)) (let* ((dir-default (dired-dwim-target-directory))
(archive-default (my-pack-file-extension (file-name-nondirectory (car infiles)))) (archive-default (my-pack-file-extension (file-name-nondirectory (car infiles))))
(archive (if (interactive-p)
(read-file-name "Output file to pack : " ;; (format "Output file to pack (default for %s) : "
;; archive-default)
dir-default
nil ;; archive-default
nil
archive-default)
(concat dir-default archive-default))))
(apply 'my-pack
archive
infiles)
(revert-buffer)))
(dired-unmark-all-marks)))
(archive ;; (if (interactive-p)
(read-file-name "Output file to pack : " ;; (format "Output file to pack (default for %s) : "
;; archive-default)
dir-default
nil ;; archive-default
nil
archive-default)
;; (concat dir-default archive-default)
)))
(apply 'my-pack
archive
infiles)))
(revert-buffer)
;; (dired-unmark-all-marks)
)

(defun my-pack-file-name-association (filename)
""
(assoc (my-file-name-extension-with-tar filename)
my-pack-program-alist))


(defun my-file-name-extension-with-tar (filename) (defun my-file-name-extension-with-tar (filename)
"if FILENAME has extension with tar, like \"tar.gz\", return that. "if FILENAME has extension with tar, like \"tar.gz\", return that.
@@ -1131,12 +1163,11 @@ otherwise, return extension normally."
(defun my-pack-file-extension (filename) (defun my-pack-file-extension (filename)
"if FILENAME has extension and it can be used for pack, return FILENAME. "if FILENAME has extension and it can be used for pack, return FILENAME.
otherwise, return FILENAME with `my-pack-default-extension'" otherwise, return FILENAME with `my-pack-default-extension'"
(if (assoc (file-name-extension filename)
my-pack-program-alist)
(if (my-pack-file-name-association filename)
filename filename
(concat filename "." my-pack-default-extension))) (concat filename "." my-pack-default-extension)))


(defvar my-7z-program
(defvar my-7z-program-name
(or (executable-find "7z") (or (executable-find "7z")
(executable-find "7za") (executable-find "7za")
(executable-find "7zr"))) (executable-find "7zr")))
@@ -1145,58 +1176,43 @@ otherwise, return FILENAME with `my-pack-default-extension'"
"7z") "7z")


(defvar my-pack-program-alist (defvar my-pack-program-alist
`(("7z" ,my-7z-program "a" ,my-7z-program "x")
("tar" "tar" "cf" "tar" "xf")
("tgz" "tar" "czf" "tar" "xzf")
("txz" "tar" "cJf" "tar" "xJf")
("zip" "zip" "-r" "unzip" nil)))
(list (list "7z" (concat my-7z-program-name " a") (concat my-7z-program-name " x"))
'("tar" "tar cf" "tar xf")
'("tgz" "tar czf" "tar xzf")
'("txz" "tar cJf" "tar xJf")
'("zip" "zip -r" "unzip")))
(string-match-p "\\.gz\\'" "aaa.gz") ; \' matches string end, $ may match the point before newline.
;; (case-fold-search nil)


(defun my-unpack (archive) (defun my-unpack (archive)
"" ""
(interactive "fArchive to extract: ") (interactive "fArchive to extract: ")
(let* ((earchive (expand-file-name archive)) (let* ((earchive (expand-file-name archive))
(ext (file-name-extension earchive))
(lst (assoc ext
my-pack-program-alist))
(com (nth 3 lst))
(op (nth 4 lst))
(args (if op
(list op earchive)
(list earchive))))
(message "unpacking %s..." archive)
(apply 'call-process
com
nil
(my-pop-to-buffer-erase-noselect "*packing output*")
t
args)
(message "unpacking %s...done." archive)))
(lst (my-pack-file-name-association earchive))
)
(if lst
(shell-command (concat (nth 2
lst)
" "
(shell-quote-argument earchive)))
(message "this is not archive file defined in `pack-program-alist'!"))))


(defun my-pack (archive &rest files) (defun my-pack (archive &rest files)
"if archive have extension for pack, use it.
otherwise, use `my-pack-default-extension'. for pack."
"pack files FILES into file ARCHIVE.
if ARCHIVE have extension defined in `pack-program-alist', use that command.
otherwise, use `pack-default-extension'. for pack."
(let* ((archive-ext (my-pack-file-extension (expand-file-name archive))) (let* ((archive-ext (my-pack-file-extension (expand-file-name archive)))
(ext (file-name-extension archive-ext))
(lst (assoc ext
my-pack-program-alist))
(com (nth 1 lst))
(op (nth 2 lst))
(args (if op
(apply 'list
op
archive-ext
files)
(apply 'list
archive-ext
files))))
(message "packing to %s..." archive)
(apply 'call-process
com
nil
(my-pop-to-buffer-erase-noselect "*packing output*")
t
args)
(message "packing to %s...done." archive)))
(lst (my-pack-file-name-association archive-ext))
)
(if lst
(shell-command (concat (nth 1 lst)
" "
(shell-quote-argument archive-ext)
" "
(mapconcat 'shell-quote-argument
files
" ")))
(message "invalid extension for packing!"))))


(defun my-pop-to-buffer-erase-noselect (buffer-or-name) (defun my-pop-to-buffer-erase-noselect (buffer-or-name)
"pop up buffer using `display-buffer' and return that buffer." "pop up buffer using `display-buffer' and return that buffer."
@@ -1518,7 +1534,7 @@ if arg given, use that eshell buffer, otherwise make new eshell buffer."
(setq p4 (point)) (setq p4 (point))
(insert " " (insert " "
(format-time-string "%a, %d %b %Y %T %z") (format-time-string "%a, %d %b %Y %T %z")
" ESHELL\n"
" eshell\n"
"last:" "last:"
(number-to-string eshell-last-command-status) (number-to-string eshell-last-command-status)
(if (= (user-uid) (if (= (user-uid)
@@ -1660,16 +1676,6 @@ when SEC is nil, stop auto save if enabled."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; misc funcs ;; misc funcs


(defvar my-frame-buffer-alist nil)

(defun my-frame-buffer-add-buffer (buffer)
""
(let ((list (or (assq (selected-frame) my-frame-buffer-alist)
(progn (add-to-list 'my-frame-buffer-alist
(list (selected-frame)))
(assq (selected-frame) my-frame-buffer-alist)))))
))

(defvar my-desktop-terminal "roxterm") (defvar my-desktop-terminal "roxterm")
(defun my-execute-terminal () (defun my-execute-terminal ()
"" ""
@@ -1853,7 +1859,7 @@ this is test, does not rename files"
(catch 'end-flag (catch 'end-flag
(while t (while t
(setq action (setq action
(read-key-sequence-vector (format "size[%dx%d] 1 to maximize; 2, 3 to split; 0 to delete; o to select other; j, l to enlarge; h, k to shrink; q to quit."
(read-key-sequence-vector (format "size[%dx%d] 1: maximize; 2, 3: split; 0: delete; o: select other; j, l: enlarge; h, k: shrink; q: quit."
(window-width) (window-width)
(window-height)))) (window-height))))
(setq c (aref action 0)) (setq c (aref action 0))


Loading…
Cancel
Save