Show
Ignore:
Timestamp:
09/27/07 19:27:24 (16 months ago)
Author:
kentaro
Message:

dotfiles/emacs/kentaro:

  • added init-autosave-buffers.el
  • added init-scheme.el
  • added init-w3m.el
  • added some utilities into init-perl.el
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dotfiles/emacs/kentaro/.emacs.d/conf/init-languages.el

    r143 r289  
    1717(global-set-key "\C-c\C-f" 'find-tag) 
    1818(global-set-key "\C-c\C-b" 'pop-tag-mark) 
     19 
     20;; infoファイル置き場を追加 
     21(setq Info-default-directory-list 
     22      (cons "~/.emacs.d/info" Info-default-directory-list)) 
     23 
     24;; リージョンを自動的に囲む 
     25;; http://sami.samhuri.net/2007/6/23/emacs-for-textmate-junkies 
     26(defun wrap-region (left right beg end) 
     27  "Wrap the region in arbitrary text, LEFT goes to the left and RIGHT goes to the right." 
     28  (interactive) 
     29  (save-excursion 
     30    (goto-char beg) 
     31    (insert left) 
     32    (goto-char (+ end (length left))) 
     33    (insert right))) 
     34 
     35(defmacro wrap-region-with-function (left right) 
     36  "Returns a function which, when called, will interactively `wrap-region-or-insert' using LEFT and RIGHT." 
     37  `(lambda () (interactive) 
     38     (wrap-region-or-insert ,left ,right))) 
     39 
     40(defun wrap-region-with-tag-or-insert () 
     41  (interactive) 
     42  (if (and mark-active transient-mark-mode) 
     43      (call-interactively 'wrap-region-with-tag) 
     44    (insert "<"))) 
     45 
     46(defun wrap-region-with-tag (tag beg end) 
     47  "Wrap the region in the given HTML/XML tag using `wrap-region'. If any 
     48attributes are specified then they are only included in the opening tag." 
     49  (interactive "*sTag (including attributes): \nr") 
     50  (let* ((elems    (split-string tag " ")) 
     51         (tag-name (car elems)) 
     52         (right    (concat "</" tag-name ">"))) 
     53    (if (= 1 (length elems)) 
     54        (wrap-region (concat "<" tag-name ">") right beg end) 
     55      (wrap-region (concat "<" tag ">") right beg end)))) 
     56 
     57(defun wrap-region-or-insert (left right) 
     58  "Wrap the region with `wrap-region' if an active region is marked, otherwise insert LEFT at point." 
     59  (interactive) 
     60  (if (and mark-active transient-mark-mode) 
     61      (wrap-region left right (region-beginning) (region-end)) 
     62    (insert left))) 
     63 
     64(global-set-key "'"  (wrap-region-with-function "'" "'")) 
     65(global-set-key "\"" (wrap-region-with-function "\"" "\"")) 
     66(global-set-key "`"  (wrap-region-with-function "`" "`")) 
     67(global-set-key "("  (wrap-region-with-function "(" ")")) 
     68(global-set-key "["  (wrap-region-with-function "[" "]")) 
     69(global-set-key "{"  (wrap-region-with-function "{" "}")) 
     70(global-set-key "<"  'wrap-region-with-tag-or-insert)