# HG changeset patch # User Oleksandr Gavenko # Date 1487756262 -7200 # Node ID ab33594a818925f336e9dd9e5ab72714057def16 # Parent c0c3d88cd779f7de9cd6cf333d509fdcdb78899f Follow common prefixing schema for my functions. diff -r c0c3d88cd779 -r ab33594a8189 .emacs-my --- a/.emacs-my Tue Feb 21 11:22:31 2017 +0200 +++ b/.emacs-my Wed Feb 22 11:37:42 2017 +0200 @@ -69,7 +69,7 @@ ;; Also '-q' prevent loading your init file. (setq inhibit-default-init nil) ; t/nil -(defun my-debug (mode) +(defun my/debug (mode) "With prefix enable enter to debuger and show backtrace when problems occur, with double prefix enable debugging on event and signal, else disable breaking to debugger." @@ -107,7 +107,7 @@ (insert-file-contents (locate-file library load-path '("" ".el"))) (my/eval-buffer))) -(my-debug nil) +(my/debug nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "user info") @@ -134,7 +134,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "my defun, defmacro, defvar") -(defmacro my-filter (pred list) +(defmacro my/filter (pred list) "Construct list with elements from LIST which satisfy PRED." (let ( (r (make-symbol "r_")) ) `(let ( (,r (list nil)) ) @@ -144,7 +144,7 @@ ,list) (cdr ,r)))) -(defun my-fold (f x list) +(defun my/fold (f x list) "Recursively applies (F i j) to LIST starting with X. For example, (fold F X '(1 2 3)) computes (F (F (F X 1) 2) 3)." (let ((li list) (x2 x)) @@ -183,11 +183,11 @@ (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) -(defun my-emacs-lisp-mode-hook () +(defun my/emacs-lisp-mode-hook () (setq tab-width 8)) -(add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook) - -(defun my-elisp-find-tag () +(add-hook 'emacs-lisp-mode-hook 'my/emacs-lisp-mode-hook) + +(defun my/elisp-find-tag () (interactive) (require 'etags) (ring-insert find-tag-marker-ring (point-marker)) @@ -195,7 +195,7 @@ (find-function-at-point) )) ;; Goto elisp definition. -(define-key emacs-lisp-mode-map (kbd "M-.") 'my-elisp-find-tag) +(define-key emacs-lisp-mode-map (kbd "M-.") 'my/elisp-find-tag) (if (not (fboundp 'global-prettify-symbols-mode)) ;; http://www.emacswiki.org/emacs/PrettyLambda @@ -205,7 +205,7 @@ (1 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char 'greek-iso8859-7 107)) font-lock-keyword-face)) ))) (global-prettify-symbols-mode 1)) -(defun my-dump-funcs () +(defun my/dump-funcs () "Dump all function calls in current buffer. Useful to explore elisp API from somebody else files." (interactive) @@ -222,7 +222,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "mode groups") -(defmacro my-defun-rename-symb-tree (name doc func) +(defmacro my/defun-rename-symb-tree (name doc func) "Travel by TREE and applies FUNC to each symbol." `(defun ,name (tree) ,doc @@ -236,24 +236,24 @@ (t (error "Only tree of symbols allowed")) ))) -(my-defun-rename-symb-tree - my-feature2mode +(my/defun-rename-symb-tree + my/feature2mode "Convert TREE of features to TREE of modes for these features. Single symbol allowed." (lambda (symb) (intern (concat (symbol-name symb) "-mode")))) -(my-defun-rename-symb-tree - my-mode2hook +(my/defun-rename-symb-tree + my/mode2hook "Convert TREE of modes to TREE of hooks for these modes. Single symbol allowed." (lambda (symb) (intern (concat (symbol-name symb) "-hook"))) ) -(my-defun-rename-symb-tree - my-mode2modemap +(my/defun-rename-symb-tree + my/mode2modemap "Convert TREE of modes to TREE of keymaps for these modes. Single symbol allowed." (lambda (symb) (intern (concat (symbol-name symb) "-map"))) ) -(defvar my-devel-mode-list +(defvar my/devel-mode-list '( sh-mode script-mode tcl-mode c-mode c++-mode java-mode js-mode @@ -271,11 +271,11 @@ ) "List of development modes.") -(defvar my-devel-mode-hook-list - (my-mode2hook my-devel-mode-list) +(defvar my/devel-mode-hook-list + (my/mode2hook my/devel-mode-list) "List of development mode hooks.") -(defvar my-scroll-margin-mode-list +(defvar my/scroll-margin-mode-list '( vc-dir-mode recentf-dialog-mode @@ -287,11 +287,11 @@ ) "List of modes for enabling scroll margin.") -(defvar my-scroll-margin-mode-hook-list - (my-mode2hook my-scroll-margin-mode-list) +(defvar my/scroll-margin-mode-hook-list + (my/mode2hook my/scroll-margin-mode-list) "List of mode hooks for enabling scroll margin.") -(defvar my-text-mode-list +(defvar my/text-mode-list '( text-mode outline-mode @@ -301,8 +301,8 @@ ) "List of text modes.") -(defvar my-text-mode-hook-list - (my-mode2hook my-text-mode-list) +(defvar my/text-mode-hook-list + (my/mode2hook my/text-mode-list) "List of text mode hooks.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -346,7 +346,7 @@ (setq display-buffer-reuse-frames t) -(defun my-maximize () +(defun my/maximize () ;; Next code work with Emacs 21.4, 22.3, 23.1. (let ( (px (display-pixel-width)) @@ -365,7 +365,7 @@ (when window-system (if (fboundp 'toggle-frame-maximized) (toggle-frame-maximized) - (my-maximize) )) + (my/maximize) )) (menu-bar-mode -1) (when window-system @@ -374,15 +374,15 @@ (tool-bar-mode -1) (tooltip-mode -1) (setq-default line-spacing nil) - (defun my-popup-menu () + (defun my/popup-menu () "Menu from keyboard by emulating mouse event." (interactive) (mouse-popup-menubar (list (list (/ (display-pixel-width) 2) 10) (get-buffer-window (buffer-name))) nil) ) - (global-set-key [f10] 'my-popup-menu) - (global-set-key [apps] 'my-popup-menu) - (global-set-key [menu] 'my-popup-menu) ) + (global-set-key [f10] 'my/popup-menu) + (global-set-key [apps] 'my/popup-menu) + (global-set-key [menu] 'my/popup-menu) ) ;; Prefer horizontal windows splitting. (when (>= emacs-major-version 23) @@ -482,7 +482,7 @@ (eval-when 'compile (require 'shell)) -(defvar my-use-windows-shell nil +(defvar my/use-windows-shell nil "If t 'cmdproxy.exe' will be used as shell. Affect on \\[shell] like commands. If nil, 'sh' will be used." ) @@ -500,7 +500,7 @@ )))) (defvar cygwin-mount-table--internal) -(defun my-dos2cygwin-path (path) +(defun my/dos2cygwin-path (path) "Convert DOS path to Cygwin according to current mount table." (interactive (list (read-directory-name "Enter DOS path: "))) (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path))) @@ -560,7 +560,7 @@ (ansi-color-for-comint-mode-on) -(defun my-ansi-color (&optional beg end) +(defun my/ansi-color (&optional beg end) "Interpret ANSI color esacape sequence by colorifying cotent. Operate on selected region on whole buffer." (interactive @@ -586,22 +586,22 @@ (my--eval-after-load term (define-key term-mode-map [?\t] #'term-dynamic-complete) - (defun my-term-send-delete-word-forward () (interactive) (term-send-raw-string "\ed")) - (defun my-term-send-delete-word-backward () (interactive) (term-send-raw-string "\e\C-h")) - (define-key term-raw-map [C-delete] 'my-term-send-delete-word-forward) - (define-key term-raw-map [C-backspace] 'my-term-send-delete-word-backward) - (defun my-term-send-forward-word () (interactive) (term-send-raw-string "\ef")) - (defun my-term-send-backward-word () (interactive) (term-send-raw-string "\eb")) - (define-key term-raw-map [C-left] 'my-term-send-backward-word) - (define-key term-raw-map [C-right] 'my-term-send-forward-word) - (defun my-term-send-m-right () (interactive) (term-send-raw-string "\e[1;3C")) - (defun my-term-send-m-left () (interactive) (term-send-raw-string "\e[1;3D")) - (define-key term-raw-map [M-right] 'my-term-send-m-right) - (define-key term-raw-map [M-left] 'my-term-send-m-left) ) - -(defun my-term-mode-hook () + (defun my/term-send-delete-word-forward () (interactive) (term-send-raw-string "\ed")) + (defun my/term-send-delete-word-backward () (interactive) (term-send-raw-string "\e\C-h")) + (define-key term-raw-map [C-delete] 'my/term-send-delete-word-forward) + (define-key term-raw-map [C-backspace] 'my/term-send-delete-word-backward) + (defun my/term-send-forward-word () (interactive) (term-send-raw-string "\ef")) + (defun my/term-send-backward-word () (interactive) (term-send-raw-string "\eb")) + (define-key term-raw-map [C-left] 'my/term-send-backward-word) + (define-key term-raw-map [C-right] 'my/term-send-forward-word) + (defun my/term-send-m-right () (interactive) (term-send-raw-string "\e[1;3C")) + (defun my/term-send-m-left () (interactive) (term-send-raw-string "\e[1;3D")) + (define-key term-raw-map [M-right] 'my/term-send-m-right) + (define-key term-raw-map [M-left] 'my/term-send-m-left) ) + +(defun my/term-mode-hook () (goto-address-mode 1)) -(add-hook 'term-mode-hook #'my-term-mode-hook) +(add-hook 'term-mode-hook #'my/term-mode-hook) (setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *") @@ -621,7 +621,7 @@ ;; (setq-default show-trailing-whitespace t) (setq whitespace-style '(face trailing tabs)) -(setq whitespace-global-modes (append my-devel-mode-list my-text-mode-list)) +(setq whitespace-global-modes (append my/devel-mode-list my/text-mode-list)) (ignore-errors (require 'whitespace) (global-whitespace-mode 1)) @@ -721,9 +721,9 @@ x-gtk-show-hidden-files t ) -(defun my-prevent-kill-buffer () +(defun my/prevent-kill-buffer () (if (member (buffer-name) '("*scratch*" "NOTE.org")) nil t)) -(add-to-list 'kill-buffer-query-functions 'my-prevent-kill-buffer) +(add-to-list 'kill-buffer-query-functions 'my/prevent-kill-buffer) (define-key global-map "\C-v" nil) (define-key global-map "\C-vt" (lambda nil (interactive) (switch-to-buffer "*scratch*"))) @@ -731,7 +731,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "scrolling") -(defvar my-scroll-margin 4) +(defvar my/scroll-margin 4) (setq-default ;; Set to zero as this recommend documentation. @@ -744,13 +744,13 @@ ;; Set margin only for desired modes! Do not frustrate calendar any more. (make-variable-buffer-local 'scroll-margin) -(mapc (lambda (hook) (add-hook hook (lambda nil (setq scroll-margin my-scroll-margin)))) - (delete-dups (append my-text-mode-hook-list my-devel-mode-hook-list my-scroll-margin-mode-hook-list)) ) +(mapc (lambda (hook) (add-hook hook (lambda nil (setq scroll-margin my/scroll-margin)))) + (delete-dups (append my/text-mode-hook-list my/devel-mode-hook-list my/scroll-margin-mode-hook-list)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "chars, unicode") -(defun my-print-unicode (&optional start end) +(defun my/print-unicode (&optional start end) "Print UNICODE table." (interactive "nstart: \nnend: ") (switch-to-buffer (get-buffer-create "*UNICODE*")) @@ -817,6 +817,8 @@ (cl-flet ( (grep-compute-defaults () nil) ) (call-interactively #'rgrep)))) +(ignore-errors (require 'ag)) + (defun my/ag (regex) "Search with ag from project roor without prefix and from `default-directory' with prefix." @@ -825,8 +827,6 @@ (let ((current-prefix-arg nil)) (ag-regexp regex default-directory)) (ag-project-regexp regex))) -(ignore-errors (require 'ag)) - (setq ag-highlight-search t) (when (featurep 'ag) (global-set-key [f7] 'my/ag)) @@ -877,9 +877,9 @@ (require 'hl-line) -(defun my-hl-line-range-function () +(defun my/hl-line-range-function () (cons (line-end-position) (line-beginning-position 2))) -(setq hl-line-range-function #'my-hl-line-range-function) +(setq hl-line-range-function #'my/hl-line-range-function) (set-face-attribute 'hl-line nil :inherit nil :background "light yellow") (setq global-hl-line-sticky-flag t) @@ -905,7 +905,7 @@ ;; russian-computer for SHIFT 567 is %^& (setq default-input-method 'russian-computer) -(defun my-toggle-input-method (&optional arg) +(defun my/toggle-input-method (&optional arg) (interactive "P") (if (numberp arg) (cond @@ -923,7 +923,7 @@ (activate-input-method 'TeX)) ) (toggle-input-method arg)) ) -(global-set-key (kbd "C-\\") 'my-toggle-input-method) +(global-set-key (kbd "C-\\") 'my/toggle-input-method) ;; I found this more quick method to allow `forward-word' across pronunciation ;; as a whole word. @@ -1129,7 +1129,7 @@ "If buffer too large and my cause performance issue." (< large-file-warning-threshold (buffer-size))) -(define-derived-mode my-large-file-mode fundamental-mode "LargeFile" +(define-derived-mode my/large-file-mode fundamental-mode "LargeFile" "Fixes performance issues in Emacs for large files." ;; (setq buffer-read-only t) (setq bidi-display-reordering nil) @@ -1141,7 +1141,7 @@ (set (make-local-variable 'line-number-mode) nil) (set (make-local-variable 'column-number-mode) nil) ) -(add-to-list 'magic-mode-alist (cons #'my--large-file-p #'my-large-file-mode)) +(add-to-list 'magic-mode-alist (cons #'my--large-file-p #'my/large-file-mode)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "helm") @@ -1219,7 +1219,7 @@ ;; dired-recursive-copies 'top ;; dired-recursive-deletes 'top) -(defun my-dired-up-dir () +(defun my/dired-up-dir () "'Reuse' buffer if enter to dir or open new buffer if enter to file." (interactive) ;; (dired-current-directory) always end with trailing '/' char. @@ -1235,9 +1235,9 @@ (dired-goto-file dir) ) )) -(define-key dired-mode-map (kbd "") 'my-dired-up-dir) - -(defun my-dired-enter-to-dir () +(define-key dired-mode-map (kbd "") 'my/dired-up-dir) + +(defun my/dired-enter-to-dir () "'Reuse' buffer if enter to dir or open new buffer if enter to file." (interactive) (let ( (file (dired-get-file-for-visit)) ) @@ -1246,12 +1246,12 @@ (find-file file) ))) (define-key dired-mode-map (kbd "") - 'my-dired-enter-to-dir) + 'my/dired-enter-to-dir) ;; Make behaviour same as in GUI. (unless window-system - (define-key dired-mode-map (kbd "DEL") 'my-dired-up-dir) - (define-key dired-mode-map (kbd "RET") 'my-dired-enter-to-dir)) + (define-key dired-mode-map (kbd "DEL") 'my/dired-up-dir) + (define-key dired-mode-map (kbd "RET") 'my/dired-enter-to-dir)) ;; Enable 'a' command. (put 'dired-find-alternate-file 'disabled nil) @@ -1326,10 +1326,10 @@ ;; http://tools.ietf.org/html/rfc3986 ;; http://en.wikipedia.org/wiki/Percent-encoding -(defun my-percent-decode (str) +(defun my/percent-decode (str) (decode-coding-string (let* ( (s (split-string str "%")) ) - (my-fold + (my/fold 'concat (car s) (mapcar @@ -1338,17 +1338,17 @@ (cdr s)) )) 'utf-8)) -(defun my-percent-decode-region (beg end &optional arg) +(defun my/percent-decode-region (beg end &optional arg) "Convert percent encoded string to native." (interactive "r\nP") - (let ( (result (my-percent-decode (buffer-substring-no-properties beg end))) ) + (let ( (result (my/percent-decode (buffer-substring-no-properties beg end))) ) (if (not arg) result (delete-region beg end) (insert result)) ) ) -(defun my-percent-encode (str) +(defun my/percent-encode (str) (apply 'concat (mapcar (lambda (ch) (if (or (and (<= ?a ch) (>= ?z ch)) @@ -1358,10 +1358,10 @@ (format "%%%02X" ch))) (encode-coding-string str 'utf-8) ))) -(defun my-percent-encode-region (beg end &optional arg) +(defun my/percent-encode-region (beg end &optional arg) "Encode string to percent encoding." (interactive "r\nP") - (let ( (result (my-percent-encode (buffer-substring-no-properties beg end))) ) + (let ( (result (my/percent-encode (buffer-substring-no-properties beg end))) ) (if (not arg) result (delete-region beg end) @@ -1379,7 +1379,7 @@ (t (setq browse-url-browser-function 'browse-url-mozilla))) -(defun my-cygwin-search (str) +(defun my/cygwin-search (str) "Search for Cygwin package on-line." (interactive (list (read-string "Search for Cygwin package on-line: "))) (browse-url (format "http://cygwin.com/cgi-bin2/package-grep.cgi?grep=%s" str)) @@ -1429,21 +1429,21 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "logging, logs") -(defun my-auto-revert-tail-mode-hook () +(defun my/auto-revert-tail-mode-hook () (when (string-match "/logs?/\\|\\.\\(?:log\\|out\\)\\'\\|/.xsession-errors\\'" (buffer-file-name (current-buffer))) (auto-revert-tail-mode 1) (log4-hi-mode 1) - (setq scroll-margin my-scroll-margin) + (setq scroll-margin my/scroll-margin) )) -(add-hook 'find-file-hook 'my-auto-revert-tail-mode-hook) +(add-hook 'find-file-hook 'my/auto-revert-tail-mode-hook) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "auto-fill") (setq-default fill-column 78) -(defvar my-fill-column 100 +(defvar my/fill-column 100 "I use greater value then 78 for comment in prog source.") ;; By default used American convention - sentence and with two spaces. Change @@ -1460,7 +1460,7 @@ (setq-default calc-group-digits t) (setq-default calc-group-char "'") -(defun my-calc-region (arg beg end) +(defun my/calc-region (arg beg end) "Calculate the region and display the result in the echo area. With prefix ARG non-nil, insert the result at the end of region." (interactive "P\nr") @@ -1473,7 +1473,7 @@ (save-excursion (insert result))))) -(defun my-calc-line (arg) +(defun my/calc-line (arg) "Evaluate expression in current line and display the result in the echo area by skipping final '=' sign. With prefix ARG non-nil, insert the result at the end of line and space if @@ -1604,7 +1604,7 @@ (info-initialize) )) ;; Info index nodes for automake under Debian. -(defvar my-fix-for-automake-info-lookup +(defvar my/fix-for-automake-info-lookup '(("(automake-1.11)Macro Index" nil "^`" "['(]") ("(automake-1.11)Variable Index" nil @@ -1612,7 +1612,7 @@ ("(automake-1.11)General Index" nil "^`" "['(]"))) -;; Add `my-fix-for-automake-info-lookup' entries to the end of doc-spec for +;; Add `my/fix-for-automake-info-lookup' entries to the end of doc-spec for ;; some modes. (my--eval-after-load info-look (mapc @@ -1621,7 +1621,7 @@ (mapc (lambda (doc-spec-item) (setcdr (last doc-spec) (list doc-spec-item))) - my-fix-for-automake-info-lookup))) + my/fix-for-automake-info-lookup))) '(makefile-mode autoconf-mode)) (info-lookup-maybe-add-help :mode 'makefile-gmake-mode @@ -1673,7 +1673,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "figlet") -(defun my-figlet-region (&optional b e) +(defun my/figlet-region (&optional b e) (interactive "r") (shell-command-on-region b e "figlet" (current-buffer) t) (comment-region (mark) (point))) @@ -1816,13 +1816,13 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "TODO, XXX, FIXME highlight") -(dolist (mode (append my-devel-mode-list my-text-mode-list)) +(dolist (mode (append my/devel-mode-list my/text-mode-list)) (font-lock-add-keywords mode `( ( ,(concat "\\<\\(" (regexp-opt '("TODO" "FIX" "FIXME" "HACK" "XXX")) ":?\\)\\>") 1 'font-lock-warning-face t) ;; 64 times, for highlight C-u C-u C-u - ;; ("\\([^[:space:]]\\)\\1\\{63\\}" 0 'my-contrasty-face t) + ;; ("\\([^[:space:]]\\)\\1\\{63\\}" 0 'my/contrasty-face t) )) ) @@ -1833,10 +1833,10 @@ (setq mail-user-agent 'message-user-agent) -(defun my-compose-mail () +(defun my/compose-mail () (interactive) (compose-mail nil nil `(("Organization" . ,(getenv "ORGANIZATION"))))) -(global-set-key (kbd "C-x m") #'my-compose-mail) +(global-set-key (kbd "C-x m") #'my/compose-mail) (setq message-citation-line-format "On %Y-%m-%d, %N wrote: ") @@ -1858,11 +1858,11 @@ (require 'mailabbrev) (define-key message-mode-map "\e\t" 'mail-abbrev-complete-alias)) -(defun my-message-mode-hook () +(defun my/message-mode-hook () (setq fill-column 78) (turn-on-auto-fill) (flyspell-mode 1)) -(add-hook 'message-mode-hook 'my-message-mode-hook) +(add-hook 'message-mode-hook 'my/message-mode-hook) ;; Mark all my messages by "common" string in "Message-Id" field to simplify ;; lookup for followups to me. @@ -1941,13 +1941,13 @@ gnus-save-killed-list t ) -(defun my-kill-gnus () +(defun my/kill-gnus () "Kill Gnus when exiting Emacs." (let ( (gnus-interactive-exit nil) ) (gnus-group-exit) )) (my--eval-after-load gnus - (add-hook 'kill-emacs-hook 'my-kill-gnus)) + (add-hook 'kill-emacs-hook 'my/kill-gnus)) (my--eval-after-load gnus-art (setq gnus-visible-headers (concat gnus-visible-headers "\\|^Archived-At:\\|^List-URL:\\|^Message-Id:"))) @@ -2027,12 +2027,12 @@ ;; w3m-anchor is macros in newer Emacs, need definition during byte-compilation. (require 'w3m-util))) -(defun my-w3m-view-url () +(defun my/w3m-view-url () (interactive) (browse-url (w3m-anchor))) (my--eval-after-load w3m - (define-key w3m-minor-mode-map (kbd "RET") #'my-w3m-view-url) + (define-key w3m-minor-mode-map (kbd "RET") #'my/w3m-view-url) (define-key w3m-minor-mode-map (kbd "S-RET") #'w3m-safe-view-this-url) (define-key w3m-minor-mode-map (kbd "") #'backward-char) (define-key w3m-minor-mode-map (kbd "") #'forward-char) @@ -2159,20 +2159,20 @@ ;; (add-hook 'message-sent-hook 'gnus-score-followup-article) (add-hook 'message-sent-hook 'gnus-score-followup-thread)) -(defvar my-gnus-summary-kill-same-subject-min-len 8 +(defvar my/gnus-summary-kill-same-subject-min-len 8 "Minimal length of subject string to ignore this subject.") -(defun my-gnus-summary-kill-same-subject (&optional unmark) +(defun my/gnus-summary-kill-same-subject (&optional unmark) "Add negative scores for all articles with same subject." (interactive "P") (when (or (not (integerp unmark)) (< 0 unmark)) (let ( (subj (gnus-simplify-subject-fuzzy (gnus-summary-article-subject))) ) - (when (<= (length subj) my-gnus-summary-kill-same-subject-min-len) + (when (<= (length subj) my/gnus-summary-kill-same-subject-min-len) (gnus-summary-score-entry "subject" subj 's (- gnus-score-interactive-default-score) (current-time-string))))) (gnus-summary-kill-same-subject unmark)) (my--eval-after-load gnus-sum - (define-key gnus-summary-mode-map (kbd "C-k") #'my-gnus-summary-kill-same-subject)) + (define-key gnus-summary-mode-map (kbd "C-k") #'my/gnus-summary-kill-same-subject)) (defun my/gnus-mark-thread-as-read () "Mark unmarked articles in current thread as read and move to @@ -2188,13 +2188,13 @@ (my--eval-after-load gnus-sum (define-key gnus-summary-mode-map (kbd "H-k") #'my/gnus-mark-thread-as-read)) -(defun my-gnus-thread-score-function (&rest scores) +(defun my/gnus-thread-score-function (&rest scores) "If any followup have positive score assign greater available score to thread, else assign lesser available score." (let ( (max (apply 'max scores)) (min (apply 'min scores)) ) (if (< 0 max) max min))) -(setq gnus-thread-score-function #'my-gnus-thread-score-function) -(defun my-gnus-thread-total-score () +(setq gnus-thread-score-function #'my/gnus-thread-score-function) +(defun my/gnus-thread-total-score () "Helper to debug `gnus-thread-score-function' function." (interactive) (message @@ -2295,11 +2295,11 @@ ;; Handle Emacs exit. (add-hook 'kill-emacs-hook 'jabber-disconnect)) -(defvar my-chat-prompt "[%t] %n>\n") +(defvar my/chat-prompt "[%t] %n>\n") (setq - jabber-chat-foreign-prompt-format my-chat-prompt - jabber-chat-local-prompt-format my-chat-prompt - jabber-groupchat-prompt-format my-chat-prompt + jabber-chat-foreign-prompt-format my/chat-prompt + jabber-chat-local-prompt-format my/chat-prompt + jabber-groupchat-prompt-format my/chat-prompt jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n") (let ( (mgs-list '("Я тутачки, а где Вы меня ожидали?" @@ -2311,13 +2311,13 @@ (setq jabber-default-status (nth (random (length mgs-list)) mgs-list)) ) -(defvar my-jabber-users nil +(defvar my/jabber-users nil "Assoc list of jabber user group. Keys are strings, values are lists of JIDs.") -(defun my-jabber-send (group) - "GROUP is keys from `my-jabber-users'" +(defun my/jabber-send (group) + "GROUP is keys from `my/jabber-users'" (interactive - (list (completing-read "Select group: " my-jabber-users)) + (list (completing-read "Select group: " my/jabber-users)) ) (let ( (msg (if (use-region-p) @@ -2330,12 +2330,12 @@ (lambda (user) (jabber-send-message jc user "" msg "normal") ) - (cdr (assoc group my-jabber-users)) + (cdr (assoc group my/jabber-users)) ) ) ) -(global-set-key (kbd "C-x C-j C-s") 'my-jabber-send) +(global-set-key (kbd "C-x C-j C-s") 'my/jabber-send) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "erc") @@ -2400,12 +2400,12 @@ (setq-default comment-style (quote indent)) (setq-default comment-column 44) -(setq-default comment-fill-column my-fill-column) - -(mapc (lambda (hook) (add-hook hook (lambda () (setq fill-column my-fill-column)) )) - (append my-devel-mode-hook-list my-text-mode-hook-list)) - -(mapc (lambda (mode) (add-hook (my-mode2hook mode) #'hs-minor-mode)) +(setq-default comment-fill-column my/fill-column) + +(mapc (lambda (hook) (add-hook hook (lambda () (setq fill-column my/fill-column)) )) + (append my/devel-mode-hook-list my/text-mode-hook-list)) + +(mapc (lambda (mode) (add-hook (my/mode2hook mode) #'hs-minor-mode)) '(c-mode c++-mode java-mode js-mode lisp-mode emacs-lisp-mode)) (defun my/company-prog-mode-setup () @@ -2430,8 +2430,8 @@ ;; Disable: sometimes it take a long time to process large hunks. ;; Use C-c C-b on hunk by own. -;; (defun my-diff-auto-refine-mode-on () (diff-auto-refine-mode 1)) -;; (add-hook 'diff-mode-hook 'my-diff-auto-refine-mode-on) +;; (defun my/diff-auto-refine-mode-on () (diff-auto-refine-mode 1)) +;; (add-hook 'diff-mode-hook 'my/diff-auto-refine-mode-on) (when window-system (my--eval-after-load diff-mode @@ -2450,7 +2450,7 @@ ;; (setq vc-git-diff-switches "-b") ;; (setq vc-diff-switches "-b") -(defun my-vc-root-diff (prefix) +(defun my/vc-root-diff (prefix) "Same as `vc-root-diff' but for Hg with C-u show latest MQ patch and with C-u C-u show MQ patch and local changes." (interactive "P") @@ -2468,7 +2468,7 @@ (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" nil)) )))) (call-interactively 'vc-root-diff nil) )) -(global-set-key (kbd "C-x v D") 'my-vc-root-diff) +(global-set-key (kbd "C-x v D") 'my/vc-root-diff) (when window-system (setq @@ -2496,10 +2496,10 @@ (360 . "#0D80E0"))) ) -(defun my-log-edit-mode-hook () +(defun my/log-edit-mode-hook () (setq fill-column 78) ) -(add-hook 'log-edit-mode-hook 'my-log-edit-mode-hook t) +(add-hook 'log-edit-mode-hook 'my/log-edit-mode-hook t) (eval-after-load 'log-edit '(remove-hook 'log-edit-hook 'log-edit-insert-message-template)) @@ -2558,24 +2558,24 @@ (ignore-errors (require 'ansi-color) - (defun my-colorize-compilation-buffer () + (defun my/colorize-compilation-buffer () (when (eq major-mode 'compilation-mode) (ansi-color-apply-on-region compilation-filter-start (point-max)))) - (add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer)) - -(defvar my-comint-send-hist-list nil - "History list for `my-comint-send-string'." + (add-hook 'compilation-filter-hook 'my/colorize-compilation-buffer)) + +(defvar my/comint-send-hist-list nil + "History list for `my/comint-send-string'." ) -(defun my-comint-send-string (string) +(defun my/comint-send-string (string) "Send string to comint buffers. Useful for *compilation* read-only buffer. Automaticaly append final newline." (interactive - (list (read-string "Type string: " nil 'my-comint-send-hist-list)) + (list (read-string "Type string: " nil 'my/comint-send-hist-list)) ) (comint-send-string (get-buffer-process (current-buffer)) (concat string "\n")) ) (my--eval-after-load compile - (define-key compilation-mode-map [C-return] 'my-comint-send-string)) + (define-key compilation-mode-map [C-return] 'my/comint-send-string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "scons") @@ -2618,26 +2618,26 @@ (setq tags-add-tables t) -(defvar my-ido-tag-history nil - "History of tags selected using `my-ido-complete-tag'.") -(defun my-ido-complete-tag (&optional substr) +(defvar my/ido-tag-history nil + "History of tags selected using `my/ido-complete-tag'.") +(defun my/ido-complete-tag (&optional substr) "Find a tag using ido." (tags-completion-table) (let ( tag-names ) (mapatoms (lambda (x) (push (symbol-name x) tag-names)) tags-completion-table) - (ido-completing-read "Tag: " tag-names nil t substr 'my-ido-tag-history))) -(defun my-complete-tag (prefix point) + (ido-completing-read "Tag: " tag-names nil t substr 'my/ido-tag-history))) +(defun my/complete-tag (prefix point) (interactive "P\nd") (if prefix (funcall #'complete-tag) (let ( (bounds (find-tag-default-bounds)) tag ) (if (or (not bounds) (< point (car bounds)) (< (cdr bounds) point)) - (setq tag (my-ido-complete-tag)) - (setq tag (my-ido-complete-tag (buffer-substring (car bounds) (cdr bounds)))) + (setq tag (my/ido-complete-tag)) + (setq tag (my/ido-complete-tag (buffer-substring (car bounds) (cdr bounds)))) (delete-region (car bounds) (cdr bounds))) (insert tag)))) -(global-set-key [M-return] #'my-complete-tag) +(global-set-key [M-return] #'my/complete-tag) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "CEDET, semantic, SRecord") @@ -2698,7 +2698,7 @@ (global-srecode-minor-mode 1) (add-hook 'prog-mode-hook 'srecode-minor-mode) - (defun my-srecode-reload-templates () + (defun my/srecode-reload-templates () "Reload all templates under `srecode-map-load-path'. Useful during template developing." (interactive) @@ -2728,13 +2728,13 @@ ;; (ignore-errors (require 'cedet-idutils)) - (defun my-c-mode-cedet-hook () + (defun my/c-mode-cedet-hook () ;; (local-set-key [C-return] 'semantic-complete-symbol) ;; (local-set-key [C-return] 'semantic-complete-analyze-inline) ;; (local-set-key "." 'semantic-complete-self-insert) ;; (local-set-key ">" 'semantic-complete-self-insert) ) - (add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook) + (add-hook 'c-mode-common-hook 'my/c-mode-cedet-hook) (ignore-errors (require 'semantic/ia) @@ -2756,13 +2756,13 @@ (require 'imenu) -(defun my-imenu-to-menubar () +(defun my/imenu-to-menubar () "Force imenu building when (menu-bar-mode -1)." (when imenu-generic-expression (imenu-add-menubar-index) (run-hooks 'menu-bar-update-hook) )) -(mapc (lambda (hook) (add-hook hook 'my-imenu-to-menubar)) - my-devel-mode-hook-list) +(mapc (lambda (hook) (add-hook hook 'my/imenu-to-menubar)) + my/devel-mode-hook-list) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "windows inf files for driver installin") @@ -2825,7 +2825,7 @@ (setq c-echo-syntactic-information-p t) -(defun my-c-mode-common-hook () +(defun my/c-mode-common-hook () ;; Automatically inserte newlines after special characters such as brace, comma, semi-colon, and colon. (c-toggle-auto-newline -1) ;; Delete all preceding whitespace by DEL. @@ -2833,9 +2833,9 @@ ;; Auto indent after typing colon according to `c-hanging-colons-alist'. (c-toggle-electric-state 1) ) -(add-hook 'c-mode-common-hook 'my-c-mode-common-hook) - -(defconst my-c-style +(add-hook 'c-mode-common-hook 'my/c-mode-common-hook) + +(defconst my/c-style '((c-tab-always-indent . t) (c-comment-only-line-offset . 4) (c-hanging-braces-alist @@ -2883,8 +2883,8 @@ (c-echo-syntactic-information-p . t)) "My C Programming Style") -(defun my-c-mode-style-hook () - (c-add-style "my" my-c-style t) +(defun my/c-mode-style-hook () + (c-add-style "my" my/c-style t) ;; If set 'c-default-style' before 'c-add-style' ;; "Undefined style: my" error occured from 'c-get-style-variables'. (setq c-default-style @@ -2895,7 +2895,7 @@ (other . "my") )) ) -(add-hook 'c-mode-common-hook 'my-c-mode-style-hook) +(add-hook 'c-mode-common-hook 'my/c-mode-style-hook) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "python, python-mode") @@ -3085,17 +3085,17 @@ ;; Automatically save project python buffers before refactorings (setq ropemacs-confirm-saving 'nil) -(defun my-python-add-to-path (path) +(defun my/python-add-to-path (path) (interactive (list (read-directory-name "Enter new path for PYTHONPATH: "))) (when (featurep 'cygwin-mount) - (setq path (my-dos2cygwin-path path))) + (setq path (my/dos2cygwin-path path))) (python-send-string (format "import sys; sys.path.append(\"%s\")" (expand-file-name path))) ) -(defun my-python-django-fix (path) +(defun my/python-django-fix (path) "XXX not work on Cygwin + naive Emacs." (interactive (list (read-directory-name "Enter new path for PYTHONPATH: "))) (when (featurep 'cygwin-mount) - (setq path (my-dos2cygwin-path path)) + (setq path (my/dos2cygwin-path path)) ) (let ((file (concat path "manage.py"))) (if (file-exists-p file) @@ -3269,7 +3269,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "html") -(defun my-html-charref-escape-region (start end) +(defun my/html-charref-escape-region (start end) (interactive "r") (save-excursion (save-restriction @@ -3282,28 +3282,28 @@ (while (search-forward ">") (replace-match ">")) ))) -(defun my-html-charref-from-char (char) +(defun my/html-charref-from-char (char) (format "&#%d;" char) ) -(defun my-html-charref-from-string (string) +(defun my/html-charref-from-string (string) (let ((res "")) (mapc - (lambda (char) (setq res (concat res (my-html-charref-from-char char)))) + (lambda (char) (setq res (concat res (my/html-charref-from-char char)))) string) res ) ) -(defun my-html-charref-escape-region2 (begin end &optional prefix) +(defun my/html-charref-escape-region2 (begin end &optional prefix) (interactive "r\nP") (if prefix (save-excursion (goto-char begin) - (insert (my-html-charref-from-string (delete-and-extract-region begin end)))) - (my-html-charref-from-string (buffer-substring begin end)) + (insert (my/html-charref-from-string (delete-and-extract-region begin end)))) + (my/html-charref-from-string (buffer-substring begin end)) )) -(defun my-html-charref-to-string (html) +(defun my/html-charref-to-string (html) "Return string with replaced decimal/hex and string charrefs by correcponding UTF-8 symbol." (let (str) @@ -3331,13 +3331,13 @@ (replace-match "&" t t)))) )) (buffer-string)))) -(defun my-html-charref-unescape-region (begin end &optional prefix) +(defun my/html-charref-unescape-region (begin end &optional prefix) (interactive "r\nP") (if prefix (save-excursion (goto-char begin) - (insert (my-html-charref-to-string (delete-and-extract-region begin end)))) - (my-html-charref-to-string (buffer-substring begin end)) + (insert (my/html-charref-to-string (delete-and-extract-region begin end)))) + (my/html-charref-to-string (buffer-substring begin end)) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -3430,7 +3430,7 @@ (eval-when 'compile (require 'psgml nil t)) -(defvar my-html-template +(defvar my/html-template '("html" (nil "\n" \n @@ -3448,8 +3448,8 @@ (unless (featurep 'psgml) (setq html-tag-alist (cons - my-html-template - (my-filter + my/html-template + (my/filter (lambda (item) (not (equal (car item) "html"))) html-tag-alist))) (add-to-list 'html-tag-alist '("script" (\n) ("type" "text/javascript") )) @@ -3548,7 +3548,7 @@ (add-hook 'sql-interactive-mode-hook (lambda () (toggle-truncate-lines 1))) -(defun my-sql-explain-paragraph () +(defun my/sql-explain-paragraph () "Send the current paragraph to the SQL process with \"explain \" keyword. Works at least for MySql/MariaDB." (interactive) @@ -3561,7 +3561,7 @@ (sql-send-string (concat "explain " (buffer-substring-no-properties start end))))) (my--eval-after-load sql - (define-key sql-mode-map (kbd "C-c C-e") 'my-sql-explain-paragraph)) + (define-key sql-mode-map (kbd "C-c C-e") 'my/sql-explain-paragraph)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (message "backuping")