Permalink
Browse files

Some perl tweaks

  • Loading branch information...
1 parent a717eb4 commit aa8bda672b4698c5f8776352056c8b1acb527591 @scfrazer committed Mar 7, 2012
Showing with 28 additions and 10 deletions.
  1. +14 −0 init.el
  2. BIN lisp/my-perl.elc
  3. +14 −10 lisp/src/my-perl.el
View
14 init.el
@@ -885,6 +885,19 @@ In the shell command, the file(s) will be substituted wherever a '%' is."
(interactive)
(set-buffer-modified-p (not (buffer-modified-p))))
+(defun my-toggle-quotes ()
+ "Toggle between single/double quotes."
+ (interactive)
+ (let ((pos (point))
+ (char (if (= (char-after) ?') ?\" ?')))
+ (forward-sexp)
+ (delete-char -1)
+ (insert char)
+ (goto-char pos)
+ (delete-char 1)
+ (insert char)
+ (backward-char)))
+
(defun my-toggle-window-split ()
"Toggle between horizontal/vertical split.
Only works if there are exactly two windows."
@@ -1201,6 +1214,7 @@ Does not set point. Does nothing if mark ring is empty."
(my-keys-define "C-`" 'next-error)
(my-keys-define "C-c #" 'my-convert-to-base)
(my-keys-define "C-c $" 'my-delete-trailing-whitespace)
+(my-keys-define "C-c '" 'my-toggle-quotes)
(my-keys-define "C-c +" 'my-inc-num)
(my-keys-define "C-c ." 'my-kill-results-buffer)
(my-keys-define "C-c ;" 'my-insert-comment-line)
View
Binary file not shown.
View
@@ -23,16 +23,20 @@
(add-to-list 'flymake-allowed-file-name-masks '(cperl-mode flymake-perlcritic-init flymake-perlcritic-cleanup))
-(defun my-perl-tidy (&optional beg end)
+(defun my-perl-tidy (&optional arg)
"Run perltidy on marked region, or entire buffer."
- (interactive "*")
- (let ((pos (point)))
- (if (region-active-p)
- (setq beg (region-beginning)
- end (region-end))
- (setq beg (point-min)
- end (point-max)))
- (shell-command-on-region beg end "perltidy -q" nil t)
- (goto-char pos)))
+ (interactive "*P")
+ (let ((pos (point))
+ (profile "~/.perltidyrc")
+ beg end)
+ (when arg
+ (setq profile (read-file-name "perltidy profile: " "~/" nil t ".perltidyrc")))
+ (if (region-active-p)
+ (setq beg (region-beginning)
+ end (region-end))
+ (setq beg (point-min)
+ end (point-max)))
+ (shell-command-on-region beg end (concat "perltidy -q -pro=" (expand-file-name profile)) nil t)
+ (goto-char pos)))
(provide 'my-perl)

0 comments on commit aa8bda6

Please sign in to comment.