;;; -*- Mode: Emacs-Lisp -*- ;;; ;;; Time-stamp: <1999-09-02, 17:13:25, mrz@isun34> ;; ;; [1999-07-09] .XEMACS-functions ;; (C) René Scholz ;; contains misc functions, for keybindings etc., which I have written ;; myself. (defun my-html-colors () "Korrigiere die Farben und Fonts im HTML-Mode." (interactive) (hm--html-minor-mode) (set-face-foreground 'bold "dodgerblue") (set-face-font 'bold my-fixed-font) (set-face-font 'bold-italic my-fixed-font) (set-face-font 'italic my-fixed-font) (set-face-font 'html-helper-italic-face my-fixed-font) (set-face-foreground 'html-helper-bold-face "red") (set-face-font 'html-helper-italic-face "fixed") (set-face-foreground 'hm--html-help-face "dodgerblue") (font-lock-fontify-buffer) ) (defun my-current-time-string-for-html () "My own formatting of a time-string for html-footers, Ausgabeformat: \"Fri, 28. Aug 1998   20:28:41 MET DST\"." (interactive) (let ( (time (current-time-string)) ) (concat ;;(substring time 0 3) ", " ; Wochentag (Fri) ;;(replace-in-string ;; (substring time 8 10) "^ " "0") ". " ; Tag (01.) ;;(substring time 4 7) " " ; Monat (Aug) ;;(substring time 20 24) "   " ; Jahr (1998) (my-ISO-date) "   " ; ISO-DATE (substring time 11 19) " " ; Uhrzeit (nth 1 (current-time-zone)) ; MET DST ) ) ) (defun my-html-helper-default-insert-timestamp (&optional arg) "Meine timestamp insertion function. Mit Prefix ^U wird das obere
weggelassen. Funktioniert noch nicht, da save-buffer das ^U nicht weiterreicht." (interactive "*P") (let ((time (current-time-string))) ;(beginning-of-line) (if (not arg) (progn (insert "
\n") (previous-line 1) (sgml-indent-or-tab) (previous-line -1) )) (beginning-of-line) (insert "\n") (previous-line 1) (sgml-indent-or-tab) (previous-line -1) (beginning-of-line) (insert "Last modified:  " (my-current-time-string-for-html) "  \n") (previous-line 1) (sgml-indent-or-tab) (previous-line -1) (beginning-of-line) (insert "by René Scholz
\n") (previous-line 1) (sgml-indent-or-tab) (previous-line -1) (beginning-of-line) (insert "
\n") (previous-line 1) (sgml-indent-or-tab) (previous-line -1) (sgml-indent-or-tab) ) ) (defun my-korrigiere-fill-column () "Falls (window-width) < fill-column+3, fill-column verkleinern." (interactive) (if (< (window-width) 79) ( setq fill-column (- (window-width) 3)) ) ) (defun my-delete-1 () "Löscht Zeichen und whitespace, dann indent." (interactive) (if(char= (char-after) ?\n) (progn (delete-char 1) (delete-horizontal-space) (insert " ") (sgml-indent-or-tab) ) (if(or (char= (char-after) ?\ ) (char= (char-after) ?\t)) (progn (delete-horizontal-space) (sgml-indent-or-tab) (insert " ") ) (delete-char 1) ))) (defun my-beatify-html-code () "Macht HTML schön: A HREF u.ä. groß, löschen." (interactive) (save-excursion (goto-char (point-min)) (while(search-forward "" nil t) (replace-match "")) (goto-char (point-min)) (while(search-forward """ nil t) (replace-match "\"")) (goto-char (point-min)) (while(search-forward-regexp "

]+>" nil t) (replace-match "

")) (goto-char (point-min)) (while(search-forward-regexp "" nil t) (replace-match "")) (goto-char (point-min)) (while(search-forward-regexp "<[/a-z0-9A-Z]+>" nil t) (upcase-region (match-beginning 0) (match-end 0)) ) (goto-char (point-min)) (while(search-forward "" nil t) (replace-match "")) (goto-char (point-min)) (while(search-forward "" nil t) (replace-match "")) (goto-char (point-min)) ) ) (defun my-edlex-word () "Translate word into german via edLex." (interactive) (save-excursion (mouse-set-point (mouse-position-as-motion-event)) (split-window-vertically) (backward-word 1) (mark-word 1) (copy-to-register 1234 (region-beginning) (region-end)) (zmacs-deactivate-region) (backward-word -1) (setq english_word (get-register 1234)) ;(message "word= |%s|" english_word) (shell-command (concat "edLex " english_word "&")) (read-string "(press return) ") (other-window 1) (delete-window) (other-window -1) ) ) (defun my-load-bookmarks-from-default-dir () "Lädt das Bookmarks-File .emacs.bmk aus dem aktuellen Verzeichnis (default-directory), falls vorhanden." (interactive) (if (file-readable-p (concat default-directory ".emacs.bmk" )) (progn (message "Loading bookmarks from file: %s.emacs.bmk" default-directory) (bookmark-load ".emacs.bmk") (setq bookmark-default-file (concat default-directory ".emacs.bmk")) (define-key global-map '(shift button3) 'bookmark-menu-jump) ) )) ;; Popup window with buffer list ; from XEmacs FAQ (2.61) (defun my-cw-build-buffers () "Popup the buffer menu." (interactive "@") (run-hooks 'activate-menubar-hook) (popup-menu (car (find-menu-item current-menubar '("Buffers")))) ) ;; Popup window with recent files list (defun my-recent-files-build-buffers () "Popup the recent files menu." (interactive "@") (run-hooks 'activate-menubar-hook) (popup-menu (car (find-menu-item current-menubar '("Recent Files")))) ) (defun my-write-blank-timestamp () "Schreibt leeren Timestamp vor aktuelle Zeile." (interactive) (beginning-of-line) (insert "Time-stamp: <>\n") (previous-line 1) ) (global-set-key '(alt t) 'my-write-blank-timestamp) (defconst my-time-stamp-month-numbers '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12)) "Alist of months and their number.") (defun my-ISO-date () "Return the current date as a string in \"YYYY-MM-DD\" form." (let ((date (current-time-string))) (format "%s-%02d-%02d" (substring date -4) (cdr (assoc (substring date 4 7) my-time-stamp-month-numbers)) (string-to-int (substring date 8 10))))) (defun my-write-script-header () "Schreibt einen Header für Scripte (Perl/Shell usw) vor aktuelle Zeile. Es werden eingefügt: [ISO-DATE] . " (interactive) (beginning-of-line) (insert " [" (my-ISO-date) "] " ) (insert (buffer-name (current-buffer)) "\n") (insert " (C) René Scholz ") (beginning-of-line) ) (defun my-kill-ws-at-eol () "Löscht Whitespaces aller Zeilenenden im Buffer, außer bei \"^-- \"." (interactive) (save-excursion (let ((Lines 0)) (setq Lines (count-lines (point-min) (point-max))) ;;(message "%s lines." Lines) (goto-char (point-max)) (while(not (= Lines 0)) (end-of-line) (delete-horizontal-space) ;; if not (string= mode-name "Mail") (previous-line 1) (setq Lines (1- Lines)) ) ))) (defun my-mrz-to-Voland () "HTML-Seiten ändern zur Verwendung auf www.thur.de" (interactive) (save-excursion (goto-char (point-min)) (while(search-forward "mrz@informatik.uni-jena.de" nil t) (replace-match "Voland@Jena.Thur.de")) (goto-char (point-min)) (while(search-forward "www2.informatik.uni-jena.de/~mrz" nil t) (replace-match "www.thur.de/~Voland")) (goto-char (point-min)) (if(search-forward "&df=rene.scholz" nil t) (replace-match "&df=Voland")) (goto-char (point-min)) (if(search-forward "XEmacs" nil t) (replace-match "XEmacs")) )) (defun my-unDOS () "Enfernt alle ^M im Buffer." (interactive) (save-excursion (goto-char (point-min)) (while(search-forward " " nil t) (replace-match "")) )) ;; taken from: ;:*======================= ;:* Count words in a TeX text ;:* Sam Steingold (defun my-sds-word-count (start end) "Count lines/words/characters from START to END. Replacement for count-lines-region." (interactive "r") (let ((ost (syntax-table)) (nst (copy-syntax-table))) (modify-syntax-entry ?_ "w" nst) (modify-syntax-entry ?- "w" nst) (save-excursion (save-restriction (narrow-to-region start end) (goto-char (min start end)) (unwind-protect (progn (set-syntax-table nst) (message "Region (%d to %d) has: lines: %d; words: %d; characters: %d." start end (count-lines start end) (string-to-number (how-many "\\<"));(how-many "\\<[^\\]")) (- end start))) (set-syntax-table ost)))))) (define-key esc-map "=" 'my-sds-word-count) ; was count-line-region