;; Common part of stolfi's emacs profile ;; Last edited on 2024-03-27 09:50:05 by stolfi (message "\n=== begin my-emacs-profile.el ======================================\n") (defalias 'insert-string 'insert) ; Workaround for Emacs 26.1 bug (setq inhibit-startup-message t) (setq vm-inhibit-startup-message nil) ; test ;;;;;;;;;; MISCELLANEOUS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Ensure a final newline when saving a file (setq require-final-newline t) ;; Don't add/keep extra space after periods (setq sentence-end-double-space nil) ;; Stop at the end of the file, not just add lines (setq next-line-add-newlines nil) ;; Allow eval-expression (put 'eval-expression 'disabled nil) ;; Don't use TAB for indentation (setq-default indent-tabs-mode nil) ;; Switches for "lpr" (setq lpr-switches (list "-h")) ;; Maximum number of messages to keep in log buffer (setq message-log-max 500) ;; Remember all arguments typed into the minibuffer. (setq history-length t) ;; Disable annoying tooltips (tooltip-mode -1) ; We prefer it 24-hour clock, but we don't need it really: (setq display-time-24hr-format t) (setq display-time-day-and-date nil) (display-time-mode 0) ; Disable audible bell (setq visible-bell nil) (setq ring-bell-function 'flash-mode-line) (defun flash-mode-line () (invert-face 'mode-line) (run-with-timer 0.1 nil 'invert-face 'mode-line) ) ; Use UTF-8 when sending buffer data to a shell command: (setq default-process-coding-system '(utf-8 . utf-8)) ;;;;;;;;;; DISPLAY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Max size of "buffers" menu: (setq buffers-menu-max-size 30) ;; Rules for splitting windows: (setq split-height-threshold 25) (setq split-width-threshold 9999) ;; Better frame titles (setq frame-title-format (concat "%b - emacs@" (system-name))) (setq default-frame-alist (append (list (cons 'width (frame-width)) (cons 'height (frame-height)) ) ' ( (icon-type . nil) (internal-border-width . 4) ) default-frame-alist ) ) ;; Enable mouse wheel support (cond (window-system (mwheel-install))) ;; Sane scrolling: (setq hscroll-margin 0) (setq hscroll-step 1) (setq scroll-margin 0) (setq scroll-conservatively 99999) ; Scroll minimum needed to put point n view. (if (eq window-system 'x) (progn (menu-bar-mode 0) ;; suppress menu bar (tool-bar-mode 0) ;; suppress the tool bar. (scroll-bar-mode -1) ;; suppress scroll bars (transient-mark-mode -1) (mouse-wheel-mode 1) (setq mode-line-inverse-video t) (setq x-pointer-shape x-pointer-left-ptr) (set-mouse-color "purple") ) ) ;; Don't truncate lines on narrow windows (setq truncate-partial-width-windows nil) ;;;;;; PORTUG MODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Show ISO Latin-1 accented characters. ;;; Note: also disables multibyte characters. (standard-display-european 1) ;; Show CTRL-codes as "^M" not "\015": (setq-default ctl-arrow 1) (defun toggle-portug () "set default input method to `portuguese-prefix', and toggles its status [stolfi]" (interactive) (setq default-input-method "portuguese-prefix") (toggle-input-method) ) (fset 'portug 'toggle-portug) (add-hook 'text-mode-hook (function (lambda () (auto-fill-mode 0))) t ; after existing hooks ) ;;; I want to see what I got: (setq inhibit-eol-conversion t) ;;;;;; PRELOAD COMMONLY USED STUFF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; (load "complete") ; (load "execcmd") ; (garbage-collect) ;;;;;;; DIRED ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (load "dired") ; (load "dired-support") (garbage-collect) ;; Recomendavel para seguir symlinks (A.Mandel?): (setq dired-listing-switches "-al") (defun dired-mouse-find-file-same-window (event) "In dired, visit the file or directory name you click on, reusing the current window. [stolfi]" (interactive "e") (let (file) (save-excursion (set-buffer (window-buffer (posn-window (event-end event)))) (save-excursion (goto-char (posn-point (event-end event))) (setq file (dired-get-filename nil t)) ) ) (if (null file) (message "no file on this line") (progn (select-window (posn-window (event-end event))) (find-file (file-name-sans-versions file t)) ) ) ) ) (define-key dired-mode-map [mouse-2] 'dired-mouse-find-file-same-window) ;; Disable the '!' key as shortcut to "operate on file": (define-key dired-mode-map "!" nil) ;; Add extra extensions to be ignored: (setq completion-ignored-extensions (cons ".ho" completion-ignored-extensions)) ;;;;;; MAIL MODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq user-full-name "Jorge Stolfi") (setq user-mail-address "stolfi@ic.unicamp.br") (setq query-user-mail-address t) (setq mail-citation-prefix-regexp "[ ]*[> ]*[>][ ]*") (setq mail-default-reply-to (concat (getenv "USER") "@ic.unicamp.br")) ; Prefix for included text in replies: (setq mail-yank-prefix " > ") ; Keeping track of things: (setq mail-self-blind t) ; Set up abbrev expansion in new messages: (add-hook 'mail-setup-hook 'mail-abbrevs-setup) ; Headers for 8-bit messages: (add-hook 'mail-setup-hook 'mail-insert-8bit-headers) (defun mail-insert-8bit-headers() "Insert 8bit specification headers in current buffer" (interactive) (let ( (p-here (copy-marker (point))) ) (goto-char (point-min)) (forward-line 2) (insert "MIME-Version: 1.0\n") (insert "Content-Transfer-Encoding: 8bit\n") (insert "Content-Type: text/plain; charset=iso-8859-1\n") (goto-char p-here) ) nil ) ;;;;;; VM MAILER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'vm "vm" "*Read mail under Emacs. Optional first arg FOLDER specifies the folder to visit. It defaults to the value of vm-primary-inbox. The folder buffer is put into VM mode, a major mode for reading mail. Visiting the primary inbox causes any contents of the system mailbox to be moved and appended to the resulting buffer. All the messages can be read by repeatedly pressing SPC. Messages are marked for deletion with `d', and saved to a folder with `s'. Quitting VM with `q' expunges messages marked for deletion and saves the buffered folder to disk. See the documentation for vm-mode for more information." t) (autoload 'vm-visit-folder "vm" "*Visit a mail file. VM will parse and present its messages to you in the usual way." t) ; (setq rmail-delete-after-output t) ; (load "vm-hacks") ;;;;;; MHE MAILER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq mh-summary-height 6) (setq mh-bury-show-buffer nil) (setq mh-ins-buf-prefix " > ") ;;;;;; TIME STAMP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (load "stolfi-time-stamp.el") (setq stolfi-time-stamp-initial "Last edited on DATE TIME by USER") (setq stolfi-time-stamp-start "^[^A-Za-z]*Last edited on ") (setq stolfi-time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S by %u") (setq stolfi-time-stamp-end "[^A-Za-z0-9]*$") (setq stolfi-time-stamp-active t) (setq stolfi-time-stamp-warn-inactive t) (setq stolfi-time-stamp-warn-unstamped nil) (add-hook 'write-file-hooks 'stolfi-time-stamp) ;;;;;; MAN PAGES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Isto e' muito amarrado em Suns (setq man-command "(tbl -TX %s | neqn | nroff -h -man | col -b )") ;;;;;; SPELL CHECKING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq-default ispell-program-name "/usr/bin/aspell") ;;;;;; C MODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun stolfi-beginning-of-c-func(&optional arg) "moves back to the beginning of a line believed to be outside any \ string or comment, defined to be a line that begins with '/*', '//', \ '#', '~', '_', '\\014', or an alphabetic char. With numeric argument ARG, \ repeats ARG times. If ARG is negative, moves forward instead." (interactive "p") ; (message "stolfi-beginning-of-c-func called with arg = %S" arg) (cond ( (or (not arg) (> arg 0)) (re-search-backward "^\\(/[*/]\\|[#~A-Za-z_\\014]\\)" (- (point) 24000) 'beg arg) ) ( (< arg 0) (end-of-line) (re-search-forward "^\\(/[*/]\\|[#~A-Za-z_\\014]\\)" (+ (point) 24000) 'beg (- arg)) (beginning-of-line) ) ( t (beginning-of-line) ) ) nil ) (defun stolfi-c-mode-hook() (turn-on-font-lock) (setq font-lock-beginning-of-syntax-function 'stolfi-beginning-of-c-func) (setq stolfi-time-stamp-active t) (setq stolfi-time-stamp-delete nil) (setq stolfi-time-stamp-warn-unstamped t) (setq stolfi-time-stamp-start "\\([/][/]\\|[/][*]\\)[ ]*Last edited on ") nil ) (defun stolfi-python-mode-hook() (let* ( (fdir (file-name-directory (buffer-file-name))) ) (message (concat "fdir = " fdir)) (if (string-match-p "mc857" fdir) (progn (setq stolfi-time-stamp-active nil) (setq stolfi-time-stamp-delete t) (setq stolfi-time-stamp-warn-unstamped nil) (setq stolfi-time-stamp-warn-inactive nil) ) (progn (setq stolfi-time-stamp-active t) (setq stolfi-time-stamp-delete nil) (setq stolfi-time-stamp-warn-unstamped t) (setq stolfi-time-stamp-warn-inactive t) ) ) (setq stolfi-time-stamp-start "[#][ ]*Last edited on ") (setq python-fill-docstring-style 'django) (set-fill-column 72) (modify-syntax-entry ?_ "w" (syntax-table)) nil ) ) (add-hook 'c-mode-hook 'stolfi-c-mode-hook) (add-hook 'python-mode-hook 'stolfi-python-mode-hook) ;;;;;; GNUS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Definicoes para acessar servidor NNTP no ic.unicamp.br: (defvar gnus-default-nntp-server "news.ic.unicamp.br") (defvar gnus-nntp-service "nntp") (defvar gnus-novice-user t) (defvar gnus-interactive-post t) (defvar gnus-local-domain "ic.unicamp.br") (defvar gnus-local-organization "Inst. of Computing, Univ. of Campinas") (defvar gnus-default-distribution "world") (defvar gnus-large-newsgroup 300) (defvar gnus-auto-center-summary nil) (defvar gnus-required-headers '(From Newsgroups Subject Message-ID Path Organization Distribution) ) (defvar gnus-signature-file (expand-file-name "~/vm-folders/my-news-address.txt")) ; (defvar gnus-default-article-saver 'gnus-summary-save-in-mail) (defvar gnus-default-article-saver 'gnus-summary-save-in-folder) (defvar gnus-use-long-file-name t) (defvar gnus-save-all-headers t) ;;;;;; GOPHER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'gopher "gopher" "Start a gopher session. With C-u, prompt for a gopher server." t) (autoload 'gopher-atpoint "gopher" "Try to interpret the text around point as a gopher bookmark, and dispatch to that object." t) (defvar gopher-support-bookmarks t) ;;;;;; SHELLS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) (setq rlogin-explicit-args "-8") ;;;;;; OTHER PACKAGES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'uncompress-while-visiting "uncompress2" "load uncompress" t) (autoload 'zcat-buffer "zcat") (autoload 'zcat-insert-file "zcat") (autoload 'live-find-file "live-find" "View a file with \"tail -f\"" t) (autoload 'modula-3-mode "modula3" "Modula-3 mode" t) (autoload 'makefile-mode "makefile-mode" "Makefile mode" t) (autoload 'm3makefile-mode "m3makefile-mode" "M3makefile mode" t) (autoload 'perl-www-mode "perl-www-mode" "Perl-WWW mode" t) (autoload 'stolfi-tex-mode "stolfi-tex-mode" "Stolfi's TeX mode" t) ;;;;;; DICIO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'dic-mode "dic-mode" "wordlist markup mode" t) ;;;;;; GLOBAL BINDINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (load "stolfi-hacks") ; (load "stolfi-mouse-hacks") (load "stolfi-rect") (load "stolfi-compile") (load "my-bindings") ;;; should do something smarter: (stolfi-bindings-Keytouch) ;;;;;; SYNTAX TABLES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Define '$' and '_" as punctuation, not alpha: (modify-syntax-entry ?$ "." (standard-syntax-table)) (modify-syntax-entry ?_ "." (standard-syntax-table)) (modify-syntax-entry ?$ "." text-mode-syntax-table) (modify-syntax-entry ?_ "." text-mode-syntax-table) (load-library "cc-mode") (modify-syntax-entry ?$ "." c-mode-syntax-table) (modify-syntax-entry ?_ "." c-mode-syntax-table) (modify-syntax-entry ?$ "." (syntax-table)) (modify-syntax-entry ?_ "." (syntax-table)) ;;;;;; FILE-MODE MAPPINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (electric-indent-mode -1) (add-hook 'after-change-major-mode-hook (lambda() (electric-indent-mode -1))) (setq auto-mode-alist '( ; Some standard modes: ("\\.l\\'" . lisp-mode) ("\\.lisp\\'" . lisp-mode) ; ("\\.bib\\'" . bibtex-mode) ("\\.tar\\'" . tar-mode) ("\\.org$" . org-mode) ("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode) ("[]>:/]\\..*emacs\\'" . emacs-lisp-mode) ("\\.el\\'" . emacs-lisp-mode) ("\\.py\\'" . python-mode) ("[:/]_emacs\\'" . emacs-lisp-mode) ; My own modes: ("\\.tex$" . stolfi-tex-mode) ("\\.m3make$" . m3makefile-mode) ("/m3makefile$" . m3makefile-mode) ("\\.make$" . makefile-mode) ("/makefile$" . makefile-mode) ("/Makefile$" . makefile-mode) ("\\.m3$" . modula-3-mode) ("\\.i3$" . modula-3-mode) ("\\.mg$" . modula-3-mode) ("\\.ig$" . modula-3-mode) ("/sites/.*\\.pl$" . perl-www-mode) ("\\.diccheck$" . dic-mode) ("\\.java$" . java-mode) ("\\.c$" . c-mode) ("\\.cpp$" . c-mode) ("\\.ino$" . c-mode) ("\\.h$" . c-mode) ("\\.Z$" . uncompress-while-visiting) ("\\.z$" . uncompress-while-visiting) ("\\.gz$" . uncompress-while-visiting) ; ("\\.iso$" . portug) ; ("\\.html$" . portug) ; ("\\.html-[a-zA-Z]*$" . portug) ; ("\\.dic$" . portug) ; ("/[0-9][0-9]*$" . portug) ) ) ; Attempt to fix GDB version 24 under emacs - "gdb -i=mi" broken? ; (require 'gdb-ui) ;;;;;; COLORFUL WINDOWS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The following command paints text in different colors depending on ; function. It may be pretty (well, depending on your taste), but it ; seems to slow down file loading... ; ; (load "my-hilit-profile.el") ; Fix the unreadable shell heredoc face: (load "sh-script.el") (defface sh-heredoc '((((min-colors 88) (class color) (background dark)) (:foreground "yellow1" :weight bold)) (((class color) (background dark)) (:foreground "yellow" :weight bold)) (((class color) (background light)) (:foreground "brown" )) (t (:weight bold))) "Face to show a here-document." :group 'sh-indentation) ;; Turn on font-lock mode for Emacs (cond ((not running-xemacs) (global-font-lock-mode 1) ) ) ;;;;;; EMACS SERVER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The following command enables Emacs to act as an "edit server". ; After "server-start" executed, other applications can cause this ; instance of Emacs to load and display some file "foo" by executing ; "emacsclient foo". ; ; (server-start) ;;;;;; XEMACS STUFF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if (fboundp 'tool-bar-mode) (progn (tool-bar-mode 0) (setq toolbar-news-reader (quote gnus)) ) ) (message "\n=== end my-emacs-profile.el ======================================\n")