;;{{{ Programming Keys For All Modes ;;---------------------------------- (defun ska-coding-keys (map) "Sets the key bindings which shall be available in all programming languages. Argument MAP is the local keymap (e.g. cperl-mode-map)." (define-key map '[(return)] 'newline-and-indent) (define-key map '[(control b) (d)] 'chb-insert-debug-output) (define-key map '[(control b) (\;)] 'chb-comment-region-or-line) (define-key map '[(control b) (\:)] 'chb-uncomment-region-or-line) (define-key map '[(control b) (c)] 'chb-copy-and-comment-region-or-l ) ;;}}} ;;{{{ Perl Mode ;;------------- (require 'ska-skel-perl) (defun ska-cperl-mode-keys () "Setting local keybindings for major mode: perl." (local-set-key '[(meta tab)] 'hippie-expand) (local-set-key '[(control b) (control b)] 'executable-interpret) ;; skeletons and makros MIGHT use C-b C-s as prefix if they get too many (local-set-key '[(control b) (control f)] 'ska-skel-perl-file-loop) (local-set-key '[(control b) (control s)] 'ska-skel-perl-sub) (local-set-key '[(control b) (control i)] 'ska-skel-perl-prog-id) (local-set-key '[(control b) (control o)] 'ska-skel-perl-options) ) ;;}}} (require 'skeleton) (define-skeleton ska-skel-perl-file-loop "Insert a typical perl file loop construct." "Variable name: " "my $" str " = new IO::File(\"" (let ((fname (read-string "Filename-expression: "))) (concat fname "\") or die \"Couldn't open " fname ": $!\";")) \n "while(my $line=<$" str ">) {" \n "chomp($line);" \n "next if $line=~m/^\\s*$/;" \n "next if $line=~m/^\\#/;" "\n" \n _ \n "}" '(progn (indent-according-to-mode) nil) \n "$" str "->close();" \n) ;; any other way to get a time format string? (require 'time-stamp) (define-skeleton ska-skel-perl-prog-id "Insert perl program identification." (nil) (insert-char ?# 60) \n "#" (insert-char ? 18) "PROGRAMM IDENTIFICATION" (insert-char ? 17) "#"\n (insert-char ?# 60) \n "my $program = \"" (file-name-nondirectory (file-name-sans-extension buffer-file "\";"\n "my $filedate=\"" (time-stamp-strftime "%y-%m-%d") "\";"\n "my $fileversion=\"0.01\";"\n "my $copyright = \"Copyright (C) " (substring (current-time-string) -4) " by Stefan Kamphausen\";"\n "my $title = \"$program $fileversion, $filedate - $copyright\";" ) (define-skeleton ska-skel-perl-options "Insert perl program getopt stuff." (nil) (save-excursion (if (re-search-backward "^use" (beginning-of-buffer) t) (progn (end-of-line) (newline-and-indent)) (progn (beginning-of-buffer) (while (string-match "^#" (char-to-string (char-after) (forward-line)))) (insert "use Getopt::Long;") (indent-according-to-mode) (insert "\n") nil) (insert-char ?# 60) \n "#" (insert-char ? 26) "OPTIONS" (insert-char ? 25) "#"\n (insert-char ?# 60) \n "my $opt_help = 0;"\n "my $opt_version = 0;"\n "my $ret = GetOptions("\n "\"help!\","\n "\"version!\""\n ");"\n ) ;; This is the copyright holder (if (boundp 'my-copyright-holder) (setq auto-insert-copyright my-copyright-holder) (setq auto-insert-copyright (user-full-name))) (setq auto-insert-alist '( ((perl-mode . "Perl Program") nil "#! /usr/bin/perl -w\n\n" "# File: " (file-name-nondirectory buffer-file-name) "\n" "# Time-stamp: <>\n#\n" "# Copyright (C) " (substring (current-time-string) -4) " by " auto-insert-copyright "\n#\n" "# Author: "(user-full-name) "\n#\n" (progn (save-buffer) (shell-command (format "chmod +x %s" (buffer-file-name))) "") "# Description:\n# " _ "\n" ) ;;}}} ;;{{{ Ruby Programm ((ruby-mode . "Ruby Program") nil "#! /usr/bin/env ruby\n\n" "# File: " (file-name-nondirectory buffer-file-name) "\n" "# Time-stamp: <>\n#\n" "# Copyright (C) " (substring (current-time-string) -4) " by " auto-insert-copyright "\n#\n" "# Author: "(user-full-name) "\n#\n" "# Description: " _ "\n#\n\n" "class " (replace-in-string (upcase-initials (file-name-nondirectory (file-name-sans-extension buffer-file-name))) "_" "") "\n" "def initialize()" (progn (ruby-indent-command) "") "\nend" (progn (ruby-indent-command) "") "\n end" (progn (ruby-indent-command) "") ) )) --- chb-utils missing here!!