;;; ==================================================================== ;;; Rzeczy, których będziemy dalej potrzebować ;; Sprawdza czy używamy XEmacsa czy FSF Emacsa ;; na podstawie "mike's very fine .emacs" (z www.dotfiles.com) (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version)) ;; Dodatkowe, własne biblioteki (setq load-path (append (list "~/elisp" "~/elisp/gnuplot-mode") load-path)) ;;; ==================================================================== ;;; Systemy kontroli wersji: CVS, RCS ;; CVS Commit: smarter cvs commit for VC; źle działa z RCS!!! ;; Nie ma go w domyślnej dystrybucji. ;(unless running-xemacs ; (require 'cvs-commit)) ; Dla XEmacsa możemy używać PCL CVS. ;;; ==================================================================== ;;; TeX/LaTeX i pochodne ;; --------------------------------------------------------------------- ;; Włączenie odpowiednich trybów: RefTeX, AUCTeX ;; Włączenie RefTeX-a (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t) (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; automatycznie z AUCTeX LaTeX-mode (add-hook 'latex-mode-hook 'turn-on-reftex) ; automatycznie z Emacs latex-mode ;; Włączenie (załadowanie) AUCTeX-a (require 'tex-site "tex-site" t) ; ładowanie biblioteki ;; --------------------------------------------------------------------- ;; AUCTeX -- konfiguracja ;; Główna część konfiguracji (setq-default TeX-master nil) ; Query for master file. (setq TeX-parse-self t) ; Parse file after loading. (setq TeX-auto-save t) ; Automatically save style information ;; Rozszerzenie menu TeX o możliwość dvips-owania, podglądu GhostView i drukowania ;; by Janusz Nowacki on pl.comp.dtp.tex.gust ;; na razie jeszcze nie działa ;(add-to-list 'TeX-command-list ; (list "DVIPS file" "dvips %t" 'TeX-run-TeX nil t)) ;(add-to-list 'TeX-command-list ; (list "GhostView PS file" "gv %s.ps" 'TeX-run-command nil t)) ;(add-to-list 'TeX-command-list ; (list "Print_PS" "lpr -Z twoup %s.ps" 'TeX-run-command nil t)) ;; PRINTER SUPPORT: AUCTeX config (setq lpr-command "lpr ") (defvar TeX-print-command (concat "dvips -f %s | " lpr-command " -P%p") "*Command used to print a file. First %p is expanded to the printer name, then ordinary expansion is performed as specified in TeX-expand-list.") ;; ;; Default printer list ;; (defvar TeX-printer-list '( ("default" (concat "dvips -f %s | " lpr-command ) (concat lpr-command " -q")) ("hp6" (concat "dvips -f %s | " lpr-command " -P hp5") (concat lpr-command " -q -P hp6")) ("hp6-2" (concat "dvips -f %s | mpage -2 -dp -MA4 | " lpr-command " -P hp5") (concat lpr-command " -q -P hp6")) ("twoup" (concat "dvips -f %s | " lpr-command " -P hp6 -Z twoup") (concat lpr-command " -q -P hp6")) ("hp5" (concat "dvips -f %s | " lpr-command " -P hp5") (concat lpr-command " -q -P hp5")) ("hp5-2" (concat "dvips -f %s | mpage -2 -dp -MA4 | " lpr-command " -P hp5") (concat lpr-command " -q -P hp5")) ("sp" (concat "dvips -f %s | " lpr-command " -P sp") (concat lpr-command " -q -P sp"))) "*List of available printers. The first element of each entry is the printer name. The second element is the command used to print to this printer. It defaults to the value of TeX-print-command. The third element is the command used to examine the print queue for this printer. It defaults to the value of TeX-queue-command. Any occurence of `%p' in the second or third element is expanded to the printer name given in the first element, then ordinary expansion is performed as specified in TeX-expand-list.") ;; --------------------------------------------------------------------- ;; RefTeX -- konfiguracja ;; Definicje prefiksów do dodatkowych otoczeń numerowanych ;; definicja (setq reftex-label-alist (quote (("definicja" 100 "def:" nil nil nil)))) ;; twierdzenia ;(setq reftex-label-alist (quote (("tw" 100 "thm:" nil nil nil)))) ;(setq reftex-label-alist (quote (("stw" 100 "thm:" nil nil nil)))) ;(setq reftex-label-alist (quote (("fakt" 100 "thm:" nil nil nil)))) ;; ------------------------------------------------------------------------ ;; Własne rozszerzenia LaTeX-owe (funkcje itp.). ;; Własny nagłówek LaTeX-owy (z http://info.fuw.edu.pl/~pliszka/hints/LaTeX.html) ;; by jwr (defun jwr-latex-opakuj () "Wstawiamy własny nagłówek LaTeXowy." (interactive) (save-restriction (save-excursion (beginning-of-buffer) (insert "%& --translate-file il2-t1\n") ; kodowanie ISO Latin 2 za pomocą TCX (insert "\\documentclass[10pt]{article}\n") ; domyślna klasa dokumentu (insert "\\usepackage[T1]{fontenc}\n") ; kodowanie fontów (T1, jak w TCX) (insert "%\\usepackage[latin2]{inputenc}\n") ; kodowanie ISO Latin 2 za pomocą inputenc (insert "\\usepackage{polski}\n") ; pakiet spolszczający (insert "\\begin{document}\n\n") ; początek dokumentu (end-of-buffer) (insert "\n\\end{document}\n") ; koniec dokumentu ))) ;; Introduce (interactively) tilde characters (\TeX's hard-space ~) ;; after one-letter Polish articles in the entire buffer ;; (tak naprawdę to zwykłe query-replace-regexp, czyli C-M-%) (defun tex-hard-spaces () "Replaces space after single-letter word with '~', the TeX non-breakable space" (interactive) (query-replace-regexp "\\<\\([wiazouWIAZOU]\\)\\s +" "\\1\\2~")) ;; Magic space by Michal Jankowski ;; 'Ręcznie' można ją włączyć za pomocą M-x local-set-key SPC tex-magic-space. ;; Można też użyć funkcji tex-toggle-magic-space, przypisanej do C-c SPC. (defun tex-magic-space () "Magic-space - inserts non-breakable space after a single-letter word." (interactive) (if (string-match "^\\(\\s \\|~\\)?[aeiouwz]$" (buffer-substring (max (point-min) (- (point) 2)) (point))) (insert "~") (insert " ") (and auto-fill-function (funcall auto-fill-function)))) ;; Przypisuje/wyłącza przypisanie tex-magic-space do spacji, ;; (przydatne przy pisaniu matematyki), tylko dla trybów LaTeX-owych (defun tex-toggle-magic-space () "Toggles TeX magic space, which inserts non-breakable space after a single-letter word" (interactive) ; (if (local-key-binding " " 'tex-magic-space) ; (local-unset-key " ") ; (local-set-key " " tex-magic-space) (progn (if (equal (lookup-key TeX-mode-map " ") 'tex-magic-space) (progn (define-key TeX-mode-map " " nil) (local-unset-key " ")) ; to be sure (define-key TeX-mode-map " " 'tex-magic-space)) (message "SPC is binded to %s" (lookup-key TeX-mode-map " ")))) ;; Etykiety aby były poprawnie obsługiwane przez RefTeX-a nie mogą zawierać spacji ;; UWAGA: nie interakcyjne! (za to szybkie). Nie do końca poprawne. (defun tex-sanitize-labels "Replaces whitespaces in labels by '-' character in whole buffer. Recursive (and uses recursion). Saves point and mark. Replaces in \\label, \\ref, \\eqref and \\pageref. TO DO: varioref commands." (interactive) (save-excursion (goto-char (point-min)) (setq found nil) (while (re-search-forward "\\\\\\(label\|ref\|eqref\|pageref\\){\\([-:a-zA-Z0-9]*\\)\\s-\\(.*\\)}" nil t) (replace-match "\\\\\\1{\\2-\\3}" t nil) (setq found t)) (if found (tex-sanitize-labels BUFFER)))) ;; ------------------------------------------------------------------------ ;; Przypisania klawiszy dla trybów LaTeX-owych ;; Automatyczne włączenie magicznej spacji (przywiązuje samotne ;; spójniki do nastepujących po nich wyrazów; przykład : a~teraz) ;; For AUC TeX (eval-after-load "tex" '(define-key TeX-mode-map " " 'tex-magic-space)) (eval-after-load "tex" '(define-key TeX-mode-map "\C-c " 'tex-toggle-magic-space)) ;; For tex-mode included in Emacs (eval-after-load "tex-mode" '(define-key tex-mode-map " " 'tex-magic-space)) (eval-after-load "tex-mode" '(define-key tex-mode-map "\C-c " 'tex-toggle-magic-space)) ;; Przypisanie do F5 i F6 odpowieników 'compile i 'next-error ;; dla trybu LaTeX-owego (tylko AUCTeX) (eval-after-load "tex" '(define-key TeX-mode-map [f5] 'TeX-command-master)) (eval-after-load "tex" '(define-key TeX-mode-map [f4] 'TeX-next-error)) ;;; ==================================================================== ;;; Outline mode ;; Definicja funkcji do włączenia outline mode ;(defun turn-on-outline-minor-mode () ; (outline-minor-mode 1)) ;; Automatyczne włączenie outline mode dla odpowiednich trybów ;(add-hook 'LaTeX-mode-hook 'turn-on-outline-minor-mode) ;(add-hook 'latex-mode-hook 'turn-on-outline-minor-mode) ;(add-hook 'emacs-lisp-mode-hook 'turn-on-outline-minor-mode) ;(add-hook 'TeXinfo-mode-hook 'turn-on-outline-minor-mode) ;;; ==================================================================== ;;; Polonizacja ;; --------------------------------------------------------------------- ;; Język polski jako domyślny ;; Polski słownik ortograficzny jako domyślny (set-default 'ispell-local-dictionary "polish") ;; --------------------------------------------------------------------- ;; Polska klawiatura i fonty ;; z Polskiej Strony Ogonkowej, dyskusji na pl.comp.dtp.tex i innych źródeł ;; z pliku .emacs Jacka Pliszki ;(setq font-menu-registry-encoding "iso8859-2") ;; MULE = "MULti-lingual Enhancement to GNU Emacs" ;; (na razie nie do końca chce działać) ;; ustawienie "języka" na latin-2 (set-language-environment 'Polish) ;; ustawiamy listę priorytetów kodowań ;(prefer-coding-system 'cp1250) (prefer-coding-system 'latin-2) ;; wszystkie pliki LaTeX-owe czytamy używając kodowania latin-2 ;(modify-coding-system-alist 'file "\\.tex\\'" 'latin-2) ;(modify-coding-system-alist 'file "\\.sty\\'" 'latin-2) ;; nowo tworzone pliki zapisujemy używając kodowania latin-2 ;(setq default-buffer-file-coding-system 'latin-2) ;; zainicjowanie historii - szybkie wybieranie kodowania ;(setq coding-system-history ; (append (list "emacs-mule" "cp1250" "cp852" "latin-2") ; coding-system-history)) ;; Aby kill/yank dzialalo zawsze dla tekstow wielojezycznych ;(set-selection-coding-system `emacs-mule) ;; no-MULE ;; poniższa linijka wyłącz MULE i ustawia widzenie polskich znaczkow ;; UWAGA: nie działa z XEmacsem, trzeba więc dopisać sprawdzanie zmiennej ;; running-xemacs ;(standard-display-european t) ;;; ==================================================================== ;;; Różne ;; Visible bell (no beep) (setq visible-bell t) ;; Nieskończony minibuffer (historia komunikatów) (setq minibuffer-max-depth nil) ;; Użycie kółka myszy (mouse-wheel-mode t) ;; Paste at point NOT at cursor (setq mouse-yank-at-point 't) ;; Ask to quit emacs ;; z "Jeff's concise but complete .emacs" (www.dotfiles.com) (setq kill-emacs-query-functions (cons (lambda () (yes-or-no-p "Really kill Emacs? ")) kill-emacs-query-functions)) ;; don't automatically add new lines when scrolling down at the bottom ;; of a buffer (you will need to add them using ENTER) ;; from ".emacs by hollins" (www.dotfiles.com) ;(setq next-line-add-newlines nil) ;; Provide access to system clipboard ;(setq x-select-enable-clipboard t) ;; Używamy narrow-to-region (C-c n n) bez pytania ;; Normalnie pyta się, czy na pewno czy chcesz użyć tej komendy (put 'narrow-to-region 'disabled nil) ;; --------------------------------------------------------------------- ;; Podświetlanie składni i nawiasów ;; Blinking parenthesis ;; (można wyłączyć jeśli komu przeszkadza). (if running-xemacs (progn ;XEmacs (paren-set-mode 'paren) ;podświetlanie nawiasów ) (progn ;FSF Emacs: (require 'paren) ;ładujemy bibliotekę (show-paren-mode t) ;włączamy podświetlanie parujących nawiasów ) ) ;; Font-lock-mode settings (kolorowanie składni) (if running-xemacs (progn ;XEmacs (turn-on-font-lock) ;włączenie kolorków globalnie (lazy-shot-mode) ;'leniwe' kolorowanie ) (progn ;FSF Emacs (global-font-lock-mode t) ;włączenie kolorków globalnie ;(setq font-lock-support-mode 'lazy-lock-mode) ;'leniwe' kolorowanie ) ) (setq font-lock-maximum-decoration t) ;kolorowanie na maksimum ;; --------------------------------------------------------------------- ;; Ustawienie postaci modeline ;; Add line number to the modeline (line-number-mode 1) ;; Add column number to modeline ;(column-number-mode 1) ;; show more info in taskbar/icon than just "Emacs" ;; from "Multi-platform .emacs with various tweaks" (www.dotfiles.com) (if running-xemacs (setq-default frame-title-format (list "XEmacs - %b: %f")) (setq-default frame-title-format (list "Emacs - %b: %f")) ) (setq-default icon-title-format (list "%b")) ;;; ==================================================================== ;;; Ustawienia trybów do edycji HTML/SGML/XML ;; ------------------------------------------------------------------------ ;; HTML Helper mode (XEmacs) (if running-xemacs (setq ; HTML 4.01 Transitional DTD html-helper-htmldtd-version (concat "\n") ; template html-helper-new-buffer-template '(html-helper-htmldtd-version ; DTD for HTML version "\n" ; language: Polish "\n" " " (p "Document Title: " title) "\n\n" " \n" " \n" " \n" "\n" "\n" "

" (s title) "

\n\n" "\n\n
\n" "
Jakub.Narebski@fuw.edu.pl
\n" "
Strona główna
\n" (html-helper-return-created-string) html-helper-timestamp-start html-helper-timestamp-end "\n\n\n") ) ) ;;; ==================================================================== ;;; Pisanie programów w C/C++/Objective C/Javie ;; C/C++ Mode hook (add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-hungry-state 1) ;; (define-key c-mode-map "\C-m" 'newline-and-indent) ;"Refresh" buffer (when color highlighting is wrong) (define-key c-mode-map "\C-cr" 'font-lock-fontify-buffer) )) (add-hook 'c++-mode-hook '(lambda () (c-set-style "stroustrup") ;"Refresh" buffer (when color highlighting is wrong) (define-key c-mode-map "\C-cr" 'font-lock-fontify-buffer) )) ;; --------------------------------------------------------------------- ;; cc-mode (the mode you're in when editing C, C++, and Objective C files) ;; Tell cc-mode not to check for old-style (K&R) function declarations. ;; This speeds up indenting a lot (from sample.emacs). OBSOLETE! ;(setq c-recognize-knr-p nil) ;;; ==================================================================== ;;; Ustawienia związane z różnymi trybami ;; Modes settings ;; php-mode i gnuplot-mode to tryby niestandardowe. ;(require 'php-mode) ; na razie nie używane (autoload 'c++-mode "cc-mode" "C++ Editing Mode" t) (autoload 'c-mode "cc-mode" "C Editing Mode" t) (autoload 'objc-mode "cc-mode" "Objective-C Editing Mode" t) (autoload 'java-mode "cc-mode" "Java Editing Mode" t) ;(autoload 'php-mode "php-mode" "PHP editing mode" t) (autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t) (autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot mode" t) (autoload 'css-mode "css-mode" t) ;; powiązanie rozszerzeń z trybami Emacsa (setq auto-mode-alist (append '(("\\.C$" . c++-mode) ("\\.H$" . c++-mode) ("\\.cc$" . c++-mode) ("\\.hh$" . c++-mode) ("\\.cxx$" . c++-mode) ("\\.c$" . c-mode) ("\\.h$" . c-mode) ("\\.m$" . objc-mode) ("\\.java$" . java-mode) ("\\.f$" . fortran-mode) ("\\.pf$" . fortran-mode) ("\\.hpf$" . f90-mode) ("\\.tex$" . LaTeX-mode) ("\\.sty$" . LaTeX-mode) ("\\.txt$" . text-mode) ("\\.text$" . text-mode) ("\\.awk$" . awk-mode) ("\\.perl$" . perl-mode) ("\\.pl$" . perl-mode) ("\\.tcl$" . tcl-mode) ("\\.sh$" . shell-script-mode) ; ("\\.php3$" . php-mode) ; ("\\.php$" . php-mode) ("\\.php3?$" . html-mode) ("\\.gp$" . gnuplot-mode) ("\\.gplt$" . gnuplot-mode) ("\\.css$" . css-mode) ) auto-mode-alist)) ;;; ==================================================================== ;;; Przypisania klawiszy ;; --------------------------------------------------------------------- ;; "Zwykłe" kombinacje klawiszy ;; Make the sequence "C-x w" execute the `what-line' command, ;; which prints the current line number in the echo area. ;; Currently line number is printed in modeline, so we don't need this ;(global-set-key "\C-xw" 'what-line) ;; Make the sequence "C-x M-g" execute the `goto-line' command, ;; very useful in making code work (see also `TeX-next-error`) (global-set-key "\C-x\M-g" 'goto-line) ;; Make the sequence "C-x C-a" toggle `auto-fill-mode'. ;; Powoduje, że można pisać tekst "ciurkiem" a będzie on sformatowany ;; 80 znaków w linii. Łamanie następuje na spacjach i znakach końca ;; wierszy. M-q powoduje przeformatowanie paragrafu. (global-set-key "\C-x\C-a" 'auto-fill-mode) ;; Przypisanie do klawisza M-s komendy 'server-start, ;; tak że można używać emacsclient jako edytora. C-x # kończy sesję. ;; Należy jeszcze ustawić odpowiednie zmienne: ;; * aby latex mógł użyć emacsclient jako edytora (komenda E w trakcie ;; napotkania błędu) należy ustawić zmienną ;; TEXEDIT='emacsclient +%d %s' ;; * aby cvs mógł użyć emacclient jako edytora (do edycji logów) ;; należy ustawić zmienną ;; CVSEDITOR='emacsclient' ;; Komenda setenv coś nie chce poprawnie działać... ;(defun server-start-for-cvs ; "Starts emacs server and sets CVSEDITOR to emacsclient" ; (progn ; (server-start) ; (setenv "CVSEDITOR" "emacsclient") ; ) ; ) (global-set-key "\M-s" 'server-start) ;; --------------------------------------------------------------------- ;; Klawisze funkcyjne ;; Z gnuplot-mode ;(global-set-key [(f9)] 'gnuplot-make-buffer) ;; ------------------------------------------------------------------------- ;; Klawiatura PC podobna ;(setq delete-key-deletes-forward t) ; klawisz DEL kasuje znak pod kursorem ;(load-library "pc-select") ;(pc-select-mode) ;(require 'pc-mode) ;(pc-bindings-mode) ;(pc-selection-mode) ;;; ==================================================================== ;;; Definicje różnych funkcji ;; Count words in buffer (defun count-words-buffer () "Count the number of words in current the buffer; print a message in the minibuffer with the result." (interactive) (save-excursion (let ((count 0)) (goto-char (point-min)) (while (< (point) (point-max)) (forward-word 1) (setq count (1+ count))) (message "buffer contains %d words." count)))) ;; compute the length of the marked region (defun region-length () "Count the length of the marked region" (interactive) (message (format "%d" (- (region-end) (region-beginning))))) ;; make backup files in ~/.backups/ rather than scattered around all ;; over the filesystem. ; (defun make-backup-file-name (file-name) ; "Create the non-numeric backup file name for `file-name'." ; (require 'dired) ; (if (file-exists-p "~/.backups") ; (concat (expand-file-name "~/.backups/") ; (dired-replace-in-string "/" "|" file-name)) ; (concat file-name "~"))) (defun ascii-table () "Print the ascii table. Based on a defun by Alex Schroeder " (interactive) (switch-to-buffer "*ASCII*") (erase-buffer) (insert (format "ASCII characters up to number %d.\n" 254)) (let ((i 0)) (while (< i 254) (setq i (+ i 1)) (insert (format "%4d %c\n" i i)))) (beginning-of-buffer)) (defun insert-date () "Insert date at point." (interactive) (insert (format-time-string "%a %b %e, %Y %l:%M %p"))) (defun dos2unix () "Replace DOS eolns CR LF with Unix eolns CR" (interactive) (goto-char (point-min)) (while (search-forward "\r" nil t) (replace-match ""))) (defun unix2dos () "Replace Unix eolns CR with DOS eolns CR LF" (interactive) (goto-char (point-min)) (while (search-forward "\n" nil t) (replace-match "\r\n"))) ;;; ==================================================================== ;;; Rzeczy które muszą się znajdowac na końcu pliku .emacs ;; --------------------------------------------------------------------- ;; Zapamiętywanie sesji (desktop.el) ;; (musi sie znajdowac na koncu pliku .emacs) ;; Zapamiętanie odbywa się za pomoca M-x desktop-save. ;; Plik z sesjami umieszczany jest w bieżącym katalogu. ;; Zapamiętuje niektóre zmienne globalne i listę buforów z przypisanymi ;; plikami; dla każdego bufora tryb, domyślny katalog, point, mark and ;; mark-active, czy bufor jest read-only i niektóre zmienne lokalne. ;; UWAGA: Jeśli będzie więcej zmiennych lokalnych do zapamiętania, użyj ;; 'append' zamiast 'cons' (unless running-xemacs (desktop-load-default) (setq desktop-locals-to-save (cons 'TeX-master desktop-locals-to-save)) (desktop-read)) ;; --------------------------------------------------------------------- ;; Zapamiętywanie sesji (dektopaid.el) [nie działa dobrze] ;; Zapamiętać/odtworzyć można za pomocą M-x dta-save-session ;; i M-x dta-load-session lub M-x dta-switch-session. ;; Plik z sesjami default.conf umieszczany jest w katalogu ~/.desktopaid ;; Zapamiętuje pozycję w plikach i ramki (frames). ;(autoload 'dta-hook-up "desktopaid.elc" "Desktop Aid" t) ;(dta-hook-up) ;;; ==================================================================== ;;; Customize ;; Poniższe to wynik ustawień za pomocą Help/Customize. ;; Sięgnij tam po objaśnienia. Raczej nie zmieniać ręcznie. (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(delete-selection-mode nil) '(inhibit-startup-screen t) '(safe-local-variable-values (quote ((Local . english) (ispell-local-dictionary . english)))) '(scroll-bar-mode (quote right))) '(tex-dvi-view-command "xdvi") '(query-user-mail-address nil) '(user-mail-address "jnareb@fuw.edu.pl") (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. )