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-perl.el

    r143 r289  
     1 
    12;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*- 
    23 
     
    2425            (set-face-background 'cperl-hash-face "black") 
    2526            )) 
     27 
     28;; cperl-mode初回起動時に、モジュール名を全て詰め込んだバッファを作成し、 
     29;; dabbrevでモジュール名を補完できるようにする。 
     30;; http://subtech.g.hatena.ne.jp/antipop/20070917/1190009355 
     31(add-hook 'cperl-mode-hook 
     32          (lambda () 
     33            (let ((buffer nil) (buffer-name "*PerlModules*")) 
     34              (unless (get-buffer buffer-name) 
     35                (setq buffer (generate-new-buffer buffer-name)) 
     36                (save-current-buffer 
     37                  (shell-command 
     38                   "find `perl -e 'print join(q{ }, @INC);'` -name '*.pm' -type f | xargs egrep -h -o 'package [a-zA-Z0-9:]+;' | perl -nle 's/package\s+(.+);/$1/; print' | sort | uniq" 
     39                   buffer) 
     40                  (set-buffer buffer) 
     41                  (delete-window)))))) 
     42 
     43;; use文を、C-c C-mで自動挿入。 
     44;; http://subtech.g.hatena.ne.jp/antipop/20070917/1189962499 
     45(add-hook 'cperl-mode-hook 
     46          (lambda () 
     47            (local-set-key (kbd "\C-c \C-m") 'perl-insert-use-statement))) 
     48 
     49(defun perl-insert-use-statement (current-point) 
     50  "use statement auto-insertion." 
     51  (interactive "d") 
     52  (insert-use-statement 
     53   (detect-module-name current-point) 
     54   (detect-insert-point))) 
     55 
     56(defun insert-use-statement (module-name insert-point) 
     57  (save-excursion 
     58    (goto-char insert-point) 
     59    (insert (concat "\nuse " module-name ";")))) 
     60 
     61(defun detect-insert-point () 
     62  (save-excursion 
     63    (if (re-search-backward "use .+;" 1 t) 
     64        (match-end 0) 
     65      (progn 
     66        (string-match "^$" (buffer-string)) 
     67        (match-end 0))))) 
     68 
     69(defun detect-module-name (current-point) 
     70  (let ((str (save-excursion 
     71               (buffer-substring 
     72                current-point 
     73                (progn (beginning-of-line) (point)))))) 
     74    (if (string-match "\\([[:alnum:]-_:]+\\)$" str) 
     75        (match-string 1 str) 
     76      (error "Module name not found")))) 
    2677 
    2778;; perly-sense 
     
    81132          '(lambda() 
    82133             (progn 
    83                (define-key cperl-mode-map "{" 'insert-braces) 
     134;               (define-key cperl-mode-map "{" 'insert-braces) 
    84135               (define-key cperl-mode-map "(" 'insert-parens) 
    85136               (define-key cperl-mode-map "\"" 'insert-double-quotation)