(setq load-path (append '("/space/apps/.Emacs") load-path))
;; ------------------------------------------------------------------
(load-file "~/.Emacs/save-history.el")
(load-file "~/.Emacs/align-regexp.el")
(load-file "~/.Emacs/worklog.el")
(load-file "~/.Emacs/epic.el")
(load-file "/space/local/share/emacs/21.1/lisp/faces.el")
(load-file "/space/local/share/emacs/21.1/lisp/font-lock.el")
(load-file "/space/local/share/emacs/21.1/lisp/dired.el")
(load-file "/space/local/share/emacs/21.1/lisp/net/ange-ftp.el")
(load-file "/space/local/share/emacs/21.1/lisp/progmodes/compile.el")
(setq ange-ftp-make-backup-file nil)
(display-time) ; can't be a variable, a hook?
;; ------------------------------------------------------------------
;; Frame title bar formatting to show full path of file
(setq-default
frame-title-format
(list '((buffer-file-name " %f" (dired-directory
dired-directory
(revert-buffer-function " %b"
("%b - Dir: " default-directory)))))))
(setq-default
icon-title-format
(list '((buffer-file-name " %f" (dired-directory
dired-directory
(revert-buffer-function " %b"
("%b - Dir: " default-directory)))))))
; ------------------------------------------------------------------
;; Replace "yes or no" with y or n
(defun yes-or-no-p (arg)
"An alias for y-or-n-p, because I hate having to type 'yes' or 'no'."
(y-or-n-p arg))
; ------------------------------------------------------------------
; my old ( Sept 2001 ) .emacs
;; ------------------------------------------------
;; general and text mode
;; ------------------------------------------------
(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.
'(c++-font-lock-extra-types (quote ("string" "vector" "list" "uch" "usg" "flt" "dbl" "cpx" "stg" "vuc" "vun" "vnt" "vfl" "vdo" "vcx" "vtg" "muc" "mun" "mnt" "mfl" "mdo" "mcx" "mtg")))
'(c-macro-preprocessor "/usr/local/bin/cpp -C")
'(c-tab-always-indent nil)
'(case-fold-search t)
'(column-number-mode 1)
'(cperl-electric-keywords t)
'(cperl-electric-parens t)
'(cperl-tab-always-indent nil)
'(current-language-environment "Latin-1")
'(default-input-method "latin-1-prefix")
'(default-major-mode (quote text-mode))
'(dired-listing-switches "-oaF")
'(dired-ls-F-marks-symlinks t)
'(exec-path (quote ("/usr/local/grace/bin/" "/usr/local/bin" "/usr/bin" "/home/costin/TcTbx" "/usr/local/Acrobat4/bin" "/usr/openwin/bin" "/home/costin/.fvwm/libexec/fvwm/2.2.4" "/home/costin/.fvwm/bin" "/usr/ccs/bin" "/usr/local/teTeX/bin/sparc-sun-solaris2.8" "/usr/local/libexec/emacs/21.1/sparc-sun-solaris2.8")))
'(explicit-shell-file-name "/usr/bin/tcsh")
'(file-name-handler-alist nil t)
'(fill-column 74)
'(font-lock-global-modes t)
'(fontset-default-styles (quote (bold demibold italic bold-italic)))
'(frame-background-mode (quote light))
'(global-font-lock-mode t nil (font-lock))
'(history-length 100 t)
'(kill-whole-line 1)
'(line-number-mode t)
'(list-directory-verbose-switches "-a -F -l")
'(lpr-command "myprint")
'(next-line-add-newlines nil)
'(sh-alias-alist (quote ((ksh . ksh88) (bash2 . bash) (sh5 . sh))))
'(show-paren-mode t nil (paren))
'(speedbar-show-unknown-files t)
'(standard-indent 2)
'(tab-width 3)
'(table-cell-horizontal-char 61)
'(tex-default-mode (quote latex-mode) t)
'(tex-dvi-view-command "xdvi *" t)
'(transient-mark-mode 1))
;; ------------------------------------------------------------------
;; New functions global scope
;; ------------------------------------------------------------------
(defun tc-indent()
"\tMode specific indentation followed by the beginning of next line"
(interactive)
(indent-for-tab-command)
(forward-line)
(beginning-of-line-text)
)
(defalias 'tc-just
(read-kbd-macro "C-n 2*<C-a> DEL SPC ESC \\ SPC"))
(defun tc-date ()
"Insert a nicely formated date string."
(interactive)
(insert (format-time-string "%Y-%m-%d")))
(defun tkt()
" Kill this buffer "
(interactive)
(kill-buffer nil)
)
(defun tko()
" Kill the buffer in other window "
(interactive)
(setq old-w (selected-window))
(other-window 1)
(if (equal old-w (selected-window))
(identity t)
(kill-buffer nil)
)
(other-window -1)
)
(defun tkw()
" Kill the other window "
(interactive)
(setq old-w (selected-window))
(other-window 1)
(if (equal old-w (selected-window))
(identity t)
(delete-window nil)
)
(other-window -1)
)
(defun tka()
"Killes the other buffer and the window"
(interactive)
(tko)
(tkw)
)
(defun back-other-window()
"move to back window"
(interactive)
(other-window -1)
)
(defun tc-shell()
"Go to the shell"
(interactive)
(shell)
)
(defun tc-comment(&optional arg)
"Comment region or line"
(interactive)
(if mark-active
(comment-region (mark) (point) arg)
(beginning-of-line)
(setq m1 (point-marker))
(forward-line)
(comment-region (point) (marker-position m1) arg))
)
(defun tc-recompile()
" recompile and don't show the compilation buffer"
(interactive)
(compile-internal compile-command "No more errors")
(setq old-w (selected-window))
(other-window 1)
(delete-window nil)
(other-window -1)
)
;; ------------------------------------------------------------------
;; New global key bindings
;; ------------------------------------------------------------------
(global-set-key (kbd "A-s") 'other-frame)
(global-set-key (kbd "A-j") 'tc-indent)
(global-set-key (kbd "A-c") 'tc-comment)
(global-set-key [?\M-p] 'previous-line)
(global-set-key [?\M-n] 'next-line)
(global-set-key [?\M-b] 'backward-word)
(global-set-key [?\M-f] 'forward-word)
(global-set-key [?\M-g] 'goto-line)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [C-home] 'beginning-of-buffer)
(global-set-key [C-end] 'end-of-buffer)
(global-set-key [?\C-.] 'other-window)
(global-set-key [?\C-,] 'back-other-window)
(global-set-key [?\C-z] 'undo)
(global-set-key [?\C-q] 'tkt)
(global-set-key (kbd "A-q") 'tko)
(global-set-key (kbd "ESC ESC q") 'tka)
(global-set-key [scaron] 'execute-extended-command)
(global-set-key [f13] 'info) ;Sun Props
(global-set-key [f14] 'undo) ;Sun Undo
(global-set-key [f16] 'copy-region-as-kill) ;Sun Copy
(global-set-key [f18] 'yank) ;Sun Paste
(global-set-key [f19] 'isearch-forward) ;Sun Find
(global-set-key [f20] 'kill-region) ;Sun Cut
(global-set-key [M-f12] 'tc-shell) ; Sun M-Again
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; BUFFER SWITCHING FIX
;; to NOT put current buffer in the completion list. Steve Dodd March 1998.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun s-minibuffer-complete ()
"A shell around minibuffer-complete removing the name of the current one from the buffer completion list."
(interactive)
(if s-remove-first-completion
(progn (setq s-remove-first-completion nil)
(if (consp minibuffer-completion-table)
(setq minibuffer-completion-table
(cdr minibuffer-completion-table)) ()))
())
(minibuffer-complete))
(defun s-minibuffer-complete-word ()
(interactive)
(if s-remove-first-completion
(progn (setq s-remove-first-completion nil)
(if (consp minibuffer-completion-table)
(setq minibuffer-completion-table
(cdr minibuffer-completion-table)) ()))
())
(minibuffer-complete-word)
)
(defun s-minibuffer-complete-and-exit ()
(interactive)
(if s-remove-first-completion
(progn (setq s-remove-first-completion nil)
(if (consp minibuffer-completion-table)
(setq minibuffer-completion-table
(cdr minibuffer-completion-table)) ()))
())
(minibuffer-complete-and-exit))
(defun s-switch-to-buffer ()
(interactive)
(setq s-remove-first-completion 't)
(switch-to-buffer (read-buffer "Switch to buffer: " (other-buffer))))
(setq s-remove-first-completion 'nil)
(define-key minibuffer-local-completion-map "\040" 's-minibuffer-word)
(define-key minibuffer-local-completion-map "\t" 's-minibuffer-complete)
(define-key minibuffer-local-must-match-map [return] 's-minibuffer-complete-and-exit)
(global-set-key "\C-xb" 's-switch-to-buffer)
(global-set-key [f12] 's-switch-to-buffer) ;Sun Again
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; END BUFFER SWITCHING FIX
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ------------------------------------------------
;; Text mode
;; ------------------------------------------------
(defun tc-run-make()
"run make and hope for best"
(interactive)
(shell-command "make" nil nil)
(kill-buffer "*Shell Command Output*" )
)
(add-hook 'text-mode-hook
'(lambda ()
(auto-fill-mode 1)
(local-set-key (kbd "A-m") 'tc-run-make)
))
;; ------------------------------------------------
;; Dired-mode
;; ------------------------------------------------
(defun tc-w3-browse()
" Alternate-view a file in an application "
(interactive)
(set-variable 'thef (dired-get-filename))
(browse-url-w3 (concat "file://" thef))
)
(defun tc-dired-view()
" Alternate-view a file in an application "
(interactive)
(set-variable 'thef (dired-get-filename))
(if (and (equal (file-name-extension thef) "flt") (file-regular-p thef))
(shell-command (concat "xds.sun " thef)) () )
(if (and (equal (file-name-extension thef) "pdf") (file-regular-p thef))
(shell-command (concat "acroread " thef " & ")) () )
(if (and (equal (file-name-extension thef) "ps") (file-regular-p thef))
(shell-command (concat "gv " thef " & ")) () )
(if (and (equal (file-name-extension thef) "gz") (file-regular-p thef))
(shell-command (concat "gv " thef " & ")) () )
(if (and (equal (file-name-extension thef) "agr") (file-regular-p thef))
(shell-command (concat "grace " thef " & ")) () )
(if (and (equal (file-name-extension thef) "html") (file-regular-p thef))
(tc-w3-browse))
)
(defun tc-dired-fast-view()
" Alternate-fast-view a file in an application "
(interactive)
(set-variable 'thef (dired-get-filename))
(if (and (equal (file-name-extension thef) "pdf") (file-regular-p thef))
(shell-command (concat "gv " thef)) () )
(if (and (equal (file-name-extension thef) "flt") (file-regular-p thef))
(shell-command (concat "xds.sun " thef)) () )
(if (and (equal (file-name-extension thef) "ps") (file-regular-p thef))
(shell-command (concat "gv " thef)) () )
)
(defun tc-man-view()
" Alternate man view, runs man on the pointed file "
(interactive)
(set-variable 'thef (dired-get-filename "no-dir"))
(shell-command (concat "Tman " thef))
)
(defun del-all-bak()
"Delete all backup files"
(interactive)
(dired-flag-backup-files)
(dired-do-flagged-delete t)
)
(add-hook 'dired-mode-hook
'(lambda ()
(local-set-key (kbd "A-M") 'tc-man-view)
(local-set-key (kbd "A-v") 'tc-dired-view)
(local-set-key (kbd "A-V") 'tc-dired-fast-view)
(local-set-key [?\C-~] 'del-all-bak)
))
;; ------------------------------------------------
;; Makefile edit tools
;; ------------------------------------------------
(defun tc-prolog-make()
"Inserts the makefile"
(interactive)
(insert "CC = g++ \nCPP = g++ \nARC = ar \nprefix = . \n")
(mapcar
'(lambda (x) (insert (concat (upcase x) " = $(prefix)/" x "\n" )))
'("bin" "tmp" "src" "err" "doc" "inc" "rez" "lib"))
(insert "\n\nCPPFLAGS = -g -O4 -ansi -Wall -W -I$(INC)\nCFLAGS = -g\n")
(insert "LD_LIBRARY_PATH =\nLIBS =\n\n")
(insert "LIBS += -L/usr/lib -lXext -lX11 -lm\nLHDRS =\nLOBJS =\nLAPPS =\n\n\n" )
(setq m1 (point-marker))
(insert "# " (make-string 48 ?-) "\n# cleaning evrything\n# " (make-string 48 ?-) "\n")
(insert ".PHONY : cleantcbin cleantclib cleantchdr\n")
(insert "cleantcbin :\n\trm -f $(LAPPS)\ncleantclib :\n\trm -f $(LOBJS)\n")
(insert "cleantchdr :\n\trm -f $(LHDRS)\ncleanlib:\n\trm -f $(LIB)/*\n")
(insert "clean: cleantcbin cleantclib cleantchdr\n")
(goto-char (marker-position m1))
(forward-line -2)
(setq m1 nil)
)
(defun tc-adlib-make()
"Inserts the library"
(interactive)
(set-variable 'd (read-from-minibuffer "name: " "/home/costin/"))
(set-variable 'D (upcase (file-name-nondirectory d)))
(insert D"SRC = " d"/include\n" D"LIB = " d"/lib\n"
"CPPFLAGS += -I$("D"SRC)\nLIBS += -L$("D"LIB) -l"(file-name-nondirectory d)"\n")
)
(defun tc-adclass-make()
"Inserts the class "
(interactive)
(set-variable 'd (read-from-minibuffer "name: "))
(insert "# "(make-string 48 ?-)"\n# "d"\n# "(make-string 48 ?-)"\n"
"$(INC)/"d".h: $(LHDRS) $(SRC)/"d".h\n\tcp -f $(SRC)/"d".h $(INC)/"d".h\n"
"\tchmod ugo-w $(INC)/"d".h\nLHDRS += $(INC)/"d".h\n#\n"
"$(TMP)/"d".obj: $(LHDRS) $(SRC)/"d".cc\n"
"\t$(CC) $(CPPFLAGS) -c $(SRC)/"d".cc -o $(TMP)/"d".obj\n"
"LOBJS += $(TMP)/"d".obj\n#\n"))
(defun tc-adapp-make()
"Inserts the app "
(interactive)
(set-variable 'd (read-from-minibuffer "name: "))
(insert "# "(make-string 48 ?-)"\n# "d"\n# "(make-string 48 ?-)"\n"
"$(TMP)/"d".obj: $(LHDRS) $(SRC)/"d".cc\n"
"\t$(CC) $(CPPFLAGS) -c $(SRC)/"d".cc -o $(TMP)/"d".obj\n"
d": $(LHDRS) $(TMP)/"d".obj\n"
"\t$(CC) $(CPPFLAGS) -o $(BIN)/"d" $(TMP)/"d".obj -L$(LIB) $(LIBS)\n#\n"
"LAPPS += $(BIN)/"d"\n#\n"))
;; ------------------------------------------------
;; C/C++/ObjC editing functions
;; ------------------------------------------------
; defining a proper style, named TCCSTYLE
(defconst my-c-style
'(
(c-tab-always-indent . nil)
(c-comment-only-line-offset . 2)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"TCCSTYLE")
(defun my-c-mode-common-hook ()
(auto-fill-mode 1)
(c-add-style "TCCSTYLE" my-c-style t) ; add my personal style
(c-set-offset 'member-init-intro '++) ; offset customizations
(setq tab-width 3 indent-tabs-mode nil)
(setq c-recognize-knr-p nil)
;; (c-toggle-hungry-state 1)
(define-key c-mode-base-map "\C-m" 'newline-and-indent)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;(add-hook 'c-mode-hook '(lambda () (c++-mode)))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(font-lock-builtin-face ((t (:foreground "sienna"))))
'(font-lock-comment-face ((t (:foreground "Red3"))))
'(font-lock-function-name-face ((((class color) (background light)) (:bold t :foreground "Blue2"))))
'(font-lock-keyword-face ((((class color) (background light)) (:foreground "green4"))))
'(font-lock-reference-face ((((class color) (:background dark)) (:foreground "turquoise4"))))
'(font-lock-string-face ((((class color) (background light)) (:foreground "Blue"))))
'(font-lock-variable-name-face ((t (:foreground "black")))))
;; ------------------------------------------------
;; Fancy editing capabilities
;; ------------------------------------------------
(defun cc-tcimpl()
"Inserts the TCIMPLEMENTATION stuff"
(interactive)
(insert "#ifdef TCIMPLEMENTATION\n#undef TCIMPLEMENTATION\n\n#endif //#ifdef TCIMPLEMENTATION\n")
(forward-line -2))
(defun cc-if-end()
"Inserts a #if .. #endif macro construction, promts for the condition"
(interactive)
(set-variable 'cc-if-end-var (read-from-minibuffer "#if " "_VERBOSE_"))
(insert "#if " cc-if-end-var "\n\n" "#endif //" cc-if-end-var "\n")
(forward-line -2))
(defun cc-if()
"Inserts a if(), prompts for condition"
(interactive)
(indent-according-to-mode)
(let ((beg (point)) (col (current-column)) )
(insert "if(") (setq m1 (point-marker)) (insert ")\n{\n\n};\n")
(indent-region beg (point) col)
(goto-char (marker-position m1))
(insert (read-from-minibuffer "if:"))
(setq m1 nil)
)
)
(defun cc-func()
"Inserts a function definition, prompts for type and name"
(interactive)
(indent-according-to-mode)
(let ((beg (point)) (col (current-column)) )
(insert
(read-from-minibuffer "return type: " "int")" "(read-from-minibuffer "name: " "func")"(")
(setq m1 (point-marker))
(insert ")\n{\n\n};\n")
(indent-region beg (point) col)
(goto-char (marker-position m1))
(setq m1 nil)
)
)
(defun cc-class()
"Inserts a class definition, prompt for name"
(interactive)
(indent-according-to-mode)
(let ((beg (point)) (col (current-column)) (nam (read-from-minibuffer "name: ")))
(insert "class " nam "\n{\nprivate:\npublic:\n")
(setq m1 (point-marker))
(insert "\n\t" nam "();\n")
(insert "\t~" nam "();\n")
(insert "\tvoid Info();\n")
(insert "};\n")
(indent-region beg (point) col)
(goto-char (marker-position m1))
(setq m1 nil)))
(defun h-header ()
"Insert a nicely formatted h header."
(interactive)
(set-variable 'myvar " ")
(set-variable 'myvar (file-name-nondirectory (buffer-file-name)))
(set-variable 'myflag (concat "_" (substring myvar 0 -2) "_h_" ))
(goto-char (point-min))
(newline)
(forward-line -1)
(insert "NAME: " myvar "\n")
(insert "FILE: " (buffer-file-name) "\n")
(insert "DATE: " (format-time-string "%Y-%m-%d\n"))
(insert "DESCRIPTION: \n")
(insert "EXAMPLES: \n")
(insert "BUGS: \n")
(insert "AUTHOR: " (user-full-name) "\n")
(insert (make-string 70 ?-) "\n")
(comment-region (point) (point-min))
(newline)
(insert "#ifndef " myflag "\n")
(insert "#define " myflag" \n\n\n" )
(insert "#endif //#ifndef " myflag "\n" )
(forward-line -3)
)
(defun hi-header ()
"Insert a nicely formatted h interface - implement header."
(interactive)
(set-variable 'myvar " ")
(set-variable 'myvar
(concat "_" (substring (file-name-nondirectory (buffer-file-name)) 0 -2) "_h_"))
(newline)
(insert
"#ifdef TCIMPLEMENTATION\n#undef TCIMPLEMENTATION\n#define " myvar" 2\n")
(insert "#else\n#define " myvar " 1\n#endif//#ifdef TCIMPLEMENTATION\n")
)
(defun cc-header ()
"Insert a nicely formatted cc header."
(interactive)
(set-variable 'myvar " ")
(set-variable 'myvar (file-name-nondirectory (buffer-file-name)))
(goto-char (point-min))
(newline)
(forward-line -1)
(insert "NAME: " myvar "\n")
(insert "FILE: " (buffer-file-name) "\n")
(insert "DATE: " (format-time-string "%Y-%m-%d") "\n")
(insert "DESCRIPTION: " "\n")
(insert "EXAMPLES: " "\n")
(insert "BUGS: " "\n")
(insert "AUTHOR: " (user-full-name) "\n")
(insert (make-string 70 ?-) "\n")
(newline)
(comment-region (point) (point-min))
(insert "#include " (concat "<" (substring myvar 0 -3) ".h>" ) "\n")
)
;; ------------------------------------------------------------------
;; Bruker
;; ------------------------------------------------------------------
(defun bruker-show-int()
"Inserts Bruker AU construction to show an integer"
(interactive)
(set-variable 'showedint (read-from-minibuffer "the int:"))
(insert "FETCHPAR(\"" showedint "\", &i);\nfprintf(fptr, \"" showedint " = %d\\n\", i);\n")
)
(defun bruker-show-flt()
"Inserts Bruker AU construction to show a float"
(interactive)
(set-variable 'showedflt (read-from-minibuffer "the flt:"))
(insert "FETCHPAR(\"" showedflt "\", &f);\nfprintf(fptr, \"" showedflt " = %f\\n\", f);\n")
)
(defun bruker-show-dbl()
"Inserts Bruker AU construction to show a double"
(interactive)
(set-variable 'showeddbl (read-from-minibuffer "the dbl:"))
(insert "FETCHPAR(\"" showeddbl "\", &d);\nfprintf(fptr, \"" showeddbl " = %f\\n\", d);\n")
)
; (add-hook 'c++-mode-hook
; '(lambda ()
; (local-set-key (kbd "A-d") 'cc-if-end)
; (local-set-key (kbd "A-i") 'cc-if)
; (local-set-key (kbd "A-f") 'cc-func)
; (local-set-key (kbd "A-k") 'cc-class)
; (local-set-key (kbd "A-c") 'cc-header)
; (local-set-key (kbd "A-h") 'h-header)
; ))
;; ------------------------------------------------------------------
;; General programming stuff
;; ------------------------------------------------------------------
(defun trisep()
"Inserts a separator "
(interactive)
(set-variable 'slide-number (read-from-minibuffer "Input: "))
(beginning-of-line)
(setq m1 (point-marker))
(insert (make-string 69 ?-))
(newline)
(insert "Slide : " slide-number)
(newline)
(insert (make-string 69 ?-))
(newline)
(comment-region (point) (marker-position m1))
(setq m1 nil)
(insert "\\SlTitle{}\n\\begin{slide}\n\\end{slide}\n")
;; (insert "\\markright{{\\Large \\Blue{\\hrulefill}}}\n\\begin{slide}\n\\end{slide}\n")
;; (insert "\\begin{slide}{\\flushright{\\Large \\Blue{}\\\\}}\n\\end{slide}\n")
)
(defun insert-my-header()
"Insert a general header"
(interactive)
(goto-char (point-min))
(insert "NAME:\nTime-stamp: <>\nDESCRIPTION:\nEXAMPLES:\nBUGS:\nTYPE:\nAUTHOR: " (user-full-name) "\n" )
(insert (make-string 66 ?-))
(newline)
)
(defun sep()
"Draws a commented line in a text"
(interactive)
(beginning-of-line)
(setq m1 (point-marker))
(insert (make-string 66 ?-) "\n")
(comment-region (point) (marker-position m1))
(setq m1 nil)
)
(defun tc-mark-word (arg)
"Set mark arg words away from point, beginning from the current word"
(interactive "p")
(backward-word 1)
(push-mark
(save-excursion
(forward-word arg)
(point))
nil t))
;; ------------------------------------------------------------------
;; Shell mode
;; ------------------------------------------------------------------
(defun clear-scr()
" Clear all content of the buffer "
(interactive)
(kill-region (point-min) (point-max))
)
(add-hook 'shell-mode-hook
'(lambda ()
(local-set-key [M-f4] 'clear-scr)
(setq comint-input-ignoredups t) ; if the shell history ignores duplicates
))
;; ------------------------------------------------------------------
;; Perl mode
;; ------------------------------------------------------------------
;; sburke@netadventure.net
(defun perl-eval ()
"Run selected region as Perl code"
(interactive)
(shell-command-on-region (mark) (point) "perl ")
)
(add-hook 'perl-mode-hook
'(lambda ()
(local-set-key "\M-p" 'perl-eval)
))
;;------------------------------------------------------------------
;; Various modes
;;------------------------------------------------------------------
;; (load-file "~/.Emacs/save-history.el")
;; (load-file "~/.Emacs/align-regexp.el")
;; (load-file "~/.Emacs/worklog.el")
;; (load-file "/space/local/share/emacs/21.1/lisp/faces.el")
;; (autoload 'nc "nc" nil t)
(autoload 'align "align" nil t)
(autoload 'mma-mode "~/Solaris/MyMath/mma.el" "Mathematica package file mode" t)
(setq auto-mode-alist
(cons '("\\.m\\'" . mma-mode) auto-mode-alist))
(require 'dired-single)
(require 'tex-site)
(require 'facemenu)
;; (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
;; (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)
;; (setq auto-mode-alist (append '(("\\.gp$" . gnuplot-mode))
;; auto-mode-alist))
;; ;(global-set-key [(f9)] 'gnuplot-make-buffer)
; ------------------------------------------------------------------
; Single dired buffer
; ------------------------------------------------------------------
(defun my-dired-init ()
"Bunch of stuff to run for dired, either immediately or when it's
loaded."
;; <add other stuff here>
(define-key dired-mode-map [return] 'joc-dired-single-buffer)
(define-key dired-mode-map [mouse-1] 'joc-dired-single-buffer-mouse)
(define-key dired-mode-map [?\C-q]
(function
(lambda nil (interactive) (joc-dired-single-buffer ".."))))
(define-key dired-mode-map (kbd "]")
(function
(lambda nil (interactive) (joc-dired-single-buffer ".."))))
)
;; if dired's already loaded, then the keymap will be bound
(if (boundp 'dired-mode-map)
;; we're good to go; just add our bindings
(my-dired-init)
;; it's not loaded yet, so add our bindings to the load-hook
(add-hook 'dired-load-hook 'my-dired-init))
;; ------------------------------------------------------------------
(fset 'tc-align
[?\C- C-down ?\M-x ?a ?l ?i ?g ?n return])
;; ------------------------------------------------------------------
;; cd from emacs shell in a directory with mp3 files and exectute it from the command line
(fset 'tc-electric-brace [?{ ?} left])
(global-set-key (kbd "C-{") 'tc-electric-brace)
(fset 'tc-electric-phar [?( ?) left])
(global-set-key (kbd "C-(") 'tc-electric-phar)
(fset 'tc-electric-doll [?$ ?$ left])
(global-set-key (kbd "C-$") 'tc-electric-doll)
;; (setq-default ispell-program-name "aspell")
;; Mathematica changes the Emacs...
(global-unset-key (kbd "M-k"))
(global-set-key (kbd "M-k") 'dabbrev-expand)