All pastes #283121 Raw Edit

Miscellany

public text v1 · immutable
#283121 ·published 2006-12-18 02:57 UTC
rendered paste body
(setq semanticdb-default-save-directory "/tmp")
(set-background-color "black")
(set-foreground-color "white")
(global-font-lock-mode t)
(scroll-bar-mode nil)
(menu-bar-mode nil)
(global-unset-key "\C-c\C-c")
(global-set-key "\C-c\C-x" 'goto-line)
(global-set-key "\C-c\C-c" 'compile)

(setq myincludes '("iostream.h" "vector" "string" "fstream.h" "algorithm" "math.h"))
(setq mycincludes '("stdio.h" "stdlib.h"))
(setq myjincludes '("java.io.*" "java.util.*" "cs1.*"))

(defun function-header ()
  "Add a comment block header in front of a function."
  (interactive)
  (progn
    (setq end (point))
    (beginning-of-line)
    (search-forward "(")
    (setq start-params (point))
    (search-forward ")")
    (copy-region-as-kill (- (point) 1) start-params)
    (setq parameters (car kill-ring-yank-pointer))
    (beginning-of-line)
    (copy-region-as-kill (point) end)
    (setq comment-start "/*-------------- ")
    (setq comment-end " --------------*/")
    (setq uname (getenv "USER"))
    (insert comment-start)
    (yank)
    (setq tmp (point))
    (search-backward parameters)
    (goto-char (point))
    (kill-region tmp (point))
    (insert ")")
    (insert comment-end)
    (insert "\n/*\nInputs:   ")
    (setq return-to (point))
    (insert "\nReturns: \n\n")
    (insert uname)
    (insert " ")
    (insert (format-time-string  "%D %T" (current-time)))
    (insert "\n*/\n")
    (search-backward "Inputs: ")
    (forward-word 1)
    (goto-char (+ (point) 3))
    (insert parameters)
    (setq tmp (point))
    (search-backward ":")
    (goto-char (+ (point) 3))
    (narrow-to-region (point) tmp)
    (replace-regexp ",\[ ]*" "\n         ")
    (widen)
    (goto-char return-to)
    (end-of-line)
))

(defun perl-header ()
  "Add a comment block header in front of a function."
  (interactive)
  (progn
    (setq end (point))
    (search-backward " ")
    (setq start-name (point))
    (end-of-line)
    (copy-region-as-kill start-name end)
    (setq name (car kill-ring-yank-pointer))
    (beginning-of-line)
    (copy-region-as-kill (point) end)
    (setq comment-start "#--------------------------- ")
    (setq comment-end " ---------------------------")
    (setq uname (getenv "USER"))
    (insert comment-start)
    (insert name)
    (insert comment-end)
    (insert "\n#\n#  Inputs: ")
    (setq descript-point (point))
    (insert "\n#\n# ")
    (insert uname)
    (insert "\n#\n#\n")
    (end-of-line)
    (goto-char descript-point)
))

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "ASCII")
 '(global-font-lock-mode t nil (font-lock))
'(jde-compile-option-classpath (quote ("/usr/share/kaffe/Klasses.jar")))
 '(jde-compile-option-debug (quote ("all" (t nil nil))))
 '(jde-compile-option-hide-classpath nil)
 '(jde-compiler (quote ("jikes" "")))
 

;'(jde-compile-option-classpath (quote ("/usr/share/kaffe/Klasses.jar")))
 ;'(jde-compile-option-debug (quote ("all" (t nil nil))))
 ;'(jde-compiler (quote ("jikes" "")))
  '(mouse-wheel-mode t nil (mwheel))
 '(sc-auto-fill-region-p nil)
 '(sc-electric-references-p nil)
 '(sc-nested-citation-p t)
 '(sc-preferred-header-style 0)
 '(sc-reference-tag-string ">>>")
 '(show-paren-mode t nil (paren))
 '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
 '(tool-bar-mode nil nil (tool-bar))
 '(transient-mark-mode t)
 '(uniquify-buffer-name-style (quote forward) nil (uniquify)))

;; height eas 119 originally

(defun empty-buffer-p()
  "User method"
  (if (= (buffer-size) 0)
      (quote t)
    (quote nil)))

(defun my-headers ()
(interactive)
(if (empty-buffer-p)
    (progn
      (beginning-of-buffer)
      (dolist (element myincludes "")
        (insert "#include <" element ">\n"))
      (insert "\nvoid main(){\n\n}")
      (backward-char 2)
      (indent-for-tab-command)
      (save-buffer))))

(defun my-c-headers ()
(interactive)
(if (empty-buffer-p)
    (progn
      (beginning-of-buffer)
      (dolist (element mycincludes "")
        (insert "#include <" element ">\n"))
      (insert "\nint main(){\n\nreturn 0;\n}")
      (indent-for-tab-command)
      (backward-char 12)
      (indent-for-tab-command)
      (save-buffer))))


(defun my-python ()
(interactive)
(if (empty-buffer-p)
    (progn
      (beginning-of-buffer)
      (insert "#!/usr/bin/python\n\n"))))

(defun my-perl ()
(interactive)
(if (empty-buffer-p)
    (progn
      (beginning-of-buffer)
      (insert "#!/usr/bin/perl -w\n\n"))))

(defun my-java ()
(interactive)
(if (empty-buffer-p)
    (progn
      (beginning-of-buffer)
      (setq args (car (cdr command-line-args)))
      (dolist (element myjincludes "")
        (insert "import " element ";\n"))
      (insert "\npublic class ")
      (insert(substring args 0 -5))
      (insert "\n{\npublic static void main(String[] args)\n{\n\n}\n}")
      (backward-char 7)
      (indent-for-tab-command)
      (forward-char 2)
      (indent-for-tab-command)
      (forward-char 2)
      (indent-for-tab-command)
      (backward-char 5)
      (indent-for-tab-command)
      (save-buffer))))

(add-hook 'python-mode-hook 'my-python)
(add-hook 'c-mode-hook 'my-c-headers)
(add-hook 'c++-mode-hook 'my-headers)
(add-hook 'perl-mode-hook 'my-perl)
(add-hook 'java-mode-hook 'my-java)
(add-hook 'jde-mode-hook 'my-java)

(add-hook 'c-mode-hook
            '(lambda () (global-set-key "\M-c" 'function-header))
)

(add-hook 'c++-mode-hook
            '(lambda () (global-set-key "\M-c" 'function-header))
)

(add-hook 'java-mode-hook
            '(lambda () (global-set-key "\M-c" 'function-header))
)

(add-hook 'jde-mode-hook
            '(lambda () (global-set-key "\M-c" 'function-header))
)

(add-hook 'perl-mode-hook
            '(lambda () (global-set-key "\M-c" 'perl-header))
)