Skip to content

Instantly share code, notes, and snippets.

@rassie
Created March 10, 2010 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rassie/328467 to your computer and use it in GitHub Desktop.
Save rassie/328467 to your computer and use it in GitHub Desktop.
;; CPerl-Mode
;;; cperl-mode is preferred to perl-mode
(require 'cperl-mode)
(setq cperl-hairy t)
(autoload 'tt-mode "tt-mode")
(setq auto-mode-alist
(append '(("\\.tt$" . tt-mode)) auto-mode-alist ))
(setq auto-mode-alist
(append '(("\\.tt2$" . tt-mode)) auto-mode-alist ))
;; CPerl Outline
; Outline-minor-mode key map
(define-prefix-command 'cm-map nil "Outline-")
; HIDE
(define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
(define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
(define-key cm-map "o" 'hide-other) ; Hide other branches
(define-key cm-map "c" 'hide-entry) ; Hide this entry's body
(define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
(define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
; SHOW
(define-key cm-map "a" 'show-all) ; Show (expand) everything
(define-key cm-map "e" 'show-entry) ; Show this heading's body
(define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
(define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
(define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
; MOVE
(define-key cm-map "u" 'outline-up-heading) ; Up
(define-key cm-map "n" 'outline-next-visible-heading) ; Next
(define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
(define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
(define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
(global-set-key "\M-o" cm-map)
(setq cperl-mode-hook 'my-cperl-customizations)
(defun my-cperl-customizations ()
"cperl-mode customizations that must be done after cperl-mode loads"
(outline-minor-mode)
(abbrev-mode)
)
(setq cperl-invalid-face (quote off))
(setq cperl-invalid-face nil)
(setq cperl-electric-parens 'null)
(define-key cperl-mode-map "\C-m" 'newline-and-indent)
(setq cperl-tab-always-indent t
cperl-indent-parens-as-block t)
(setq cperl-indent-level 4
cperl-close-paren-offset -4
cperl-continued-statement-offset 0
cperl-indent-parens-as-block t
cperl-tab-always-indent t)
(setq cperl-indent-level 4)
(require 'pod-mode)
(add-hook 'pod-mode-hook 'font-lock-mode)
(setq auto-mode-alist
(append auto-mode-alist
'(("\\.pod$" . pod-mode))))
(setq auto-mode-alist
(append auto-mode-alist
'(("\\.t$" . cperl-mode))))
(defun perltidy-command(start end)
"The perltidy command we pass markers to."
(shell-command-on-region start
end
"perltidy"
t
t
(get-buffer-create "*Perltidy Output*")))
;; Updated as a dwim. I like using the existing buffer rather than creating a new buffer.
(defun perltidy-dwim (arg)
"Perltidy a region of the entire buffer"
(interactive "P")
(let ((point (point)) (start) (end))
(if (and mark-active transient-mark-mode)
(setq start (region-beginning)
end (region-end))
(setq start (point-min)
end (point-max)))
(perltidy-command start end)
(goto-char point)))
(global-set-key "\C-ct" 'perltidy-dwim)
(autoload 'tt-mode "tt-mode")
(setq auto-mode-alist
(append '(("\\.tt$" . tt-mode)) auto-mode-alist ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment