.emacs-my
changeset 1490 ab33594a8189
parent 1489 c0c3d88cd779
child 1494 874f705f7be4
equal deleted inserted replaced
1489:c0c3d88cd779 1490:ab33594a8189
    67 
    67 
    68 ;; Prevent Emacs from loading 'default.el', which loaded after '.emacs'.
    68 ;; Prevent Emacs from loading 'default.el', which loaded after '.emacs'.
    69 ;; Also '-q' prevent loading your init file.
    69 ;; Also '-q' prevent loading your init file.
    70 (setq inhibit-default-init nil)         ; t/nil
    70 (setq inhibit-default-init nil)         ; t/nil
    71 
    71 
    72 (defun my-debug (mode)
    72 (defun my/debug (mode)
    73   "With prefix enable enter to debuger and show backtrace when
    73   "With prefix enable enter to debuger and show backtrace when
    74 problems occur, with double prefix enable debugging on event and
    74 problems occur, with double prefix enable debugging on event and
    75 signal, else disable breaking to debugger."
    75 signal, else disable breaking to debugger."
    76   (interactive "P")
    76   (interactive "P")
    77   (let ( (lvl1 (not (not mode))) (lvl2 (equal mode '(16))) )
    77   (let ( (lvl1 (not (not mode))) (lvl2 (equal mode '(16))) )
   105                                            '("" ".el")))))
   105                                            '("" ".el")))))
   106   (with-temp-buffer
   106   (with-temp-buffer
   107     (insert-file-contents (locate-file library load-path '("" ".el")))
   107     (insert-file-contents (locate-file library load-path '("" ".el")))
   108     (my/eval-buffer)))
   108     (my/eval-buffer)))
   109 
   109 
   110 (my-debug nil)
   110 (my/debug nil)
   111 
   111 
   112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   113 (message "user info")
   113 (message "user info")
   114 
   114 
   115 (eval-when 'compile (require 'info))
   115 (eval-when 'compile (require 'info))
   132          (when (boundp 'user-home-page) (concat ", " user-home-page))))
   132          (when (boundp 'user-home-page) (concat ", " user-home-page))))
   133 
   133 
   134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   135 (message "my defun, defmacro, defvar")
   135 (message "my defun, defmacro, defvar")
   136 
   136 
   137 (defmacro my-filter (pred list)
   137 (defmacro my/filter (pred list)
   138   "Construct list with elements from LIST which satisfy PRED."
   138   "Construct list with elements from LIST which satisfy PRED."
   139   (let ( (r (make-symbol "r_")) )
   139   (let ( (r (make-symbol "r_")) )
   140     `(let ( (,r (list nil)) )
   140     `(let ( (,r (list nil)) )
   141        (mapc (lambda (item)
   141        (mapc (lambda (item)
   142                (when (,pred item)
   142                (when (,pred item)
   143                  (nconc ,r (cons item nil))))
   143                  (nconc ,r (cons item nil))))
   144              ,list)
   144              ,list)
   145        (cdr ,r))))
   145        (cdr ,r))))
   146 
   146 
   147 (defun my-fold (f x list)
   147 (defun my/fold (f x list)
   148   "Recursively applies (F i j) to LIST starting with X.
   148   "Recursively applies (F i j) to LIST starting with X.
   149 For example, (fold F X '(1 2 3)) computes (F (F (F X 1) 2) 3)."
   149 For example, (fold F X '(1 2 3)) computes (F (F (F X 1) 2) 3)."
   150   (let ((li list) (x2 x))
   150   (let ((li list) (x2 x))
   151     (while li
   151     (while li
   152       (setq x2 (funcall f x2 (pop li)))
   152       (setq x2 (funcall f x2 (pop li)))
   181 
   181 
   182 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
   182 (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
   183 (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
   183 (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
   184 (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
   184 (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
   185 
   185 
   186 (defun my-emacs-lisp-mode-hook ()
   186 (defun my/emacs-lisp-mode-hook ()
   187   (setq tab-width 8))
   187   (setq tab-width 8))
   188 (add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook)
   188 (add-hook 'emacs-lisp-mode-hook 'my/emacs-lisp-mode-hook)
   189 
   189 
   190 (defun my-elisp-find-tag ()
   190 (defun my/elisp-find-tag ()
   191   (interactive)
   191   (interactive)
   192   (require 'etags)
   192   (require 'etags)
   193   (ring-insert find-tag-marker-ring (point-marker))
   193   (ring-insert find-tag-marker-ring (point-marker))
   194   (unless (find-variable-at-point)
   194   (unless (find-variable-at-point)
   195     (find-function-at-point)
   195     (find-function-at-point)
   196     ))
   196     ))
   197 ;; Goto elisp definition.
   197 ;; Goto elisp definition.
   198 (define-key emacs-lisp-mode-map (kbd "M-.") 'my-elisp-find-tag)
   198 (define-key emacs-lisp-mode-map (kbd "M-.") 'my/elisp-find-tag)
   199 
   199 
   200 (if (not (fboundp 'global-prettify-symbols-mode))
   200 (if (not (fboundp 'global-prettify-symbols-mode))
   201     ;; http://www.emacswiki.org/emacs/PrettyLambda
   201     ;; http://www.emacswiki.org/emacs/PrettyLambda
   202     (font-lock-add-keywords
   202     (font-lock-add-keywords
   203      'emacs-lisp-mode
   203      'emacs-lisp-mode
   204      `(("(\\<\\(lambda\\)\\>"
   204      `(("(\\<\\(lambda\\)\\>"
   205         (1 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char 'greek-iso8859-7 107)) font-lock-keyword-face)) )))
   205         (1 (progn (compose-region (match-beginning 1) (match-end 1) ,(make-char 'greek-iso8859-7 107)) font-lock-keyword-face)) )))
   206   (global-prettify-symbols-mode 1))
   206   (global-prettify-symbols-mode 1))
   207 
   207 
   208 (defun my-dump-funcs ()
   208 (defun my/dump-funcs ()
   209   "Dump all function calls in current buffer. Useful to explore
   209   "Dump all function calls in current buffer. Useful to explore
   210 elisp API from somebody else files."
   210 elisp API from somebody else files."
   211   (interactive)
   211   (interactive)
   212   (let* ( (cur-buffer (current-buffer)) (new-buffer (get-buffer-create (concat (buffer-name cur-buffer) "-funcs.el"))) symb )
   212   (let* ( (cur-buffer (current-buffer)) (new-buffer (get-buffer-create (concat (buffer-name cur-buffer) "-funcs.el"))) symb )
   213     (while (search-forward-regexp "([[:alnum:]*]" nil t)
   213     (while (search-forward-regexp "([[:alnum:]*]" nil t)
   220     ))
   220     ))
   221 
   221 
   222 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   222 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   223 (message "mode groups")
   223 (message "mode groups")
   224 
   224 
   225 (defmacro my-defun-rename-symb-tree (name doc func)
   225 (defmacro my/defun-rename-symb-tree (name doc func)
   226   "Travel by TREE and applies FUNC to each symbol."
   226   "Travel by TREE and applies FUNC to each symbol."
   227   `(defun ,name (tree)
   227   `(defun ,name (tree)
   228      ,doc
   228      ,doc
   229      (cond
   229      (cond
   230       ((symbolp tree)
   230       ((symbolp tree)
   234        (mapcar ',name tree)
   234        (mapcar ',name tree)
   235        )
   235        )
   236       (t (error "Only tree of symbols allowed"))
   236       (t (error "Only tree of symbols allowed"))
   237       )))
   237       )))
   238 
   238 
   239 (my-defun-rename-symb-tree
   239 (my/defun-rename-symb-tree
   240  my-feature2mode
   240  my/feature2mode
   241  "Convert TREE of features to TREE of modes for these features. Single symbol allowed."
   241  "Convert TREE of features to TREE of modes for these features. Single symbol allowed."
   242  (lambda (symb) (intern (concat (symbol-name symb) "-mode"))))
   242  (lambda (symb) (intern (concat (symbol-name symb) "-mode"))))
   243 
   243 
   244 (my-defun-rename-symb-tree
   244 (my/defun-rename-symb-tree
   245  my-mode2hook
   245  my/mode2hook
   246  "Convert TREE of modes to TREE of hooks for these modes. Single symbol allowed."
   246  "Convert TREE of modes to TREE of hooks for these modes. Single symbol allowed."
   247  (lambda (symb) (intern (concat (symbol-name symb) "-hook")))
   247  (lambda (symb) (intern (concat (symbol-name symb) "-hook")))
   248  )
   248  )
   249 
   249 
   250 (my-defun-rename-symb-tree
   250 (my/defun-rename-symb-tree
   251  my-mode2modemap
   251  my/mode2modemap
   252  "Convert TREE of modes to TREE of keymaps for these modes. Single symbol allowed."
   252  "Convert TREE of modes to TREE of keymaps for these modes. Single symbol allowed."
   253  (lambda (symb) (intern (concat (symbol-name symb) "-map")))
   253  (lambda (symb) (intern (concat (symbol-name symb) "-map")))
   254  )
   254  )
   255 
   255 
   256 (defvar my-devel-mode-list
   256 (defvar my/devel-mode-list
   257   '(
   257   '(
   258     sh-mode script-mode tcl-mode
   258     sh-mode script-mode tcl-mode
   259     c-mode c++-mode java-mode js-mode
   259     c-mode c++-mode java-mode js-mode
   260     python-mode perl-mode cperl-mode
   260     python-mode perl-mode cperl-mode
   261     lisp-mode
   261     lisp-mode
   269     texinfo-mode
   269     texinfo-mode
   270     gadict-mode
   270     gadict-mode
   271     )
   271     )
   272   "List of development modes.")
   272   "List of development modes.")
   273 
   273 
   274 (defvar my-devel-mode-hook-list
   274 (defvar my/devel-mode-hook-list
   275    (my-mode2hook my-devel-mode-list)
   275    (my/mode2hook my/devel-mode-list)
   276   "List of development mode hooks.")
   276   "List of development mode hooks.")
   277 
   277 
   278 (defvar my-scroll-margin-mode-list
   278 (defvar my/scroll-margin-mode-list
   279   '(
   279   '(
   280     vc-dir-mode
   280     vc-dir-mode
   281     recentf-dialog-mode
   281     recentf-dialog-mode
   282     org-agenda-grid-mode           ; XXX for this item not worked!
   282     org-agenda-grid-mode           ; XXX for this item not worked!
   283     log-view-mode
   283     log-view-mode
   285     compilation-mode
   285     compilation-mode
   286     conf-mode
   286     conf-mode
   287     )
   287     )
   288   "List of modes for enabling scroll margin.")
   288   "List of modes for enabling scroll margin.")
   289 
   289 
   290 (defvar my-scroll-margin-mode-hook-list
   290 (defvar my/scroll-margin-mode-hook-list
   291   (my-mode2hook my-scroll-margin-mode-list)
   291   (my/mode2hook my/scroll-margin-mode-list)
   292   "List of mode hooks for enabling scroll margin.")
   292   "List of mode hooks for enabling scroll margin.")
   293 
   293 
   294 (defvar my-text-mode-list
   294 (defvar my/text-mode-list
   295   '(
   295   '(
   296     text-mode
   296     text-mode
   297     outline-mode
   297     outline-mode
   298     rst-mode
   298     rst-mode
   299     diff-mode
   299     diff-mode
   300     dict-c5-mode
   300     dict-c5-mode
   301     )
   301     )
   302   "List of text modes.")
   302   "List of text modes.")
   303 
   303 
   304 (defvar my-text-mode-hook-list
   304 (defvar my/text-mode-hook-list
   305   (my-mode2hook my-text-mode-list)
   305   (my/mode2hook my/text-mode-list)
   306   "List of text mode hooks.")
   306   "List of text mode hooks.")
   307 
   307 
   308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   309 (message "MS Windows, w32, win32")
   309 (message "MS Windows, w32, win32")
   310 
   310 
   344 
   344 
   345 (eval-when 'compile (load-library "window"))
   345 (eval-when 'compile (load-library "window"))
   346 
   346 
   347 (setq display-buffer-reuse-frames t)
   347 (setq display-buffer-reuse-frames t)
   348 
   348 
   349 (defun my-maximize ()
   349 (defun my/maximize ()
   350   ;; Next code work with Emacs 21.4, 22.3, 23.1.
   350   ;; Next code work with Emacs 21.4, 22.3, 23.1.
   351   (let (
   351   (let (
   352         (px (display-pixel-width))
   352         (px (display-pixel-width))
   353         (py (display-pixel-height))
   353         (py (display-pixel-height))
   354         (fx (frame-char-width))
   354         (fx (frame-char-width))
   363     (add-to-list 'initial-frame-alist (cons 'height ty)) ))
   363     (add-to-list 'initial-frame-alist (cons 'height ty)) ))
   364 
   364 
   365 (when window-system
   365 (when window-system
   366   (if (fboundp 'toggle-frame-maximized)
   366   (if (fboundp 'toggle-frame-maximized)
   367       (toggle-frame-maximized)
   367       (toggle-frame-maximized)
   368     (my-maximize) ))
   368     (my/maximize) ))
   369 
   369 
   370 (menu-bar-mode -1)
   370 (menu-bar-mode -1)
   371 (when window-system
   371 (when window-system
   372   (mouse-avoidance-mode 'animate)
   372   (mouse-avoidance-mode 'animate)
   373   (scroll-bar-mode 1)
   373   (scroll-bar-mode 1)
   374   (tool-bar-mode -1)
   374   (tool-bar-mode -1)
   375   (tooltip-mode -1)
   375   (tooltip-mode -1)
   376   (setq-default line-spacing nil)
   376   (setq-default line-spacing nil)
   377   (defun my-popup-menu ()
   377   (defun my/popup-menu ()
   378     "Menu from keyboard by emulating mouse event."
   378     "Menu from keyboard by emulating mouse event."
   379     (interactive)
   379     (interactive)
   380     (mouse-popup-menubar
   380     (mouse-popup-menubar
   381      (list (list (/ (display-pixel-width) 2) 10) (get-buffer-window (buffer-name)))
   381      (list (list (/ (display-pixel-width) 2) 10) (get-buffer-window (buffer-name)))
   382      nil) )
   382      nil) )
   383   (global-set-key [f10] 'my-popup-menu)
   383   (global-set-key [f10] 'my/popup-menu)
   384   (global-set-key [apps] 'my-popup-menu)
   384   (global-set-key [apps] 'my/popup-menu)
   385   (global-set-key [menu] 'my-popup-menu) )
   385   (global-set-key [menu] 'my/popup-menu) )
   386 
   386 
   387 ;; Prefer horizontal windows splitting.
   387 ;; Prefer horizontal windows splitting.
   388 (when (>= emacs-major-version 23)
   388 (when (>= emacs-major-version 23)
   389   (setq split-height-threshold nil)
   389   (setq split-height-threshold nil)
   390   (setq split-width-threshold nil)
   390   (setq split-width-threshold nil)
   480 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   480 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   481 (message "shell, bash, Cygwin, MSYS")
   481 (message "shell, bash, Cygwin, MSYS")
   482 
   482 
   483 (eval-when 'compile (require 'shell))
   483 (eval-when 'compile (require 'shell))
   484 
   484 
   485 (defvar my-use-windows-shell nil
   485 (defvar my/use-windows-shell nil
   486   "If t 'cmdproxy.exe' will be used as shell.
   486   "If t 'cmdproxy.exe' will be used as shell.
   487 Affect on \\[shell] like commands. If nil, 'sh' will be used." )
   487 Affect on \\[shell] like commands. If nil, 'sh' will be used." )
   488 
   488 
   489 (defun follow-cygwin-symlink ()
   489 (defun follow-cygwin-symlink ()
   490   "Follow new-style (and also UCS-16) Cygwin symlinks."
   490   "Follow new-style (and also UCS-16) Cygwin symlinks."
   498          'utf-16-le)
   498          'utf-16-le)
   499         0 -1)                           ; -1 for stripping final \0.
   499         0 -1)                           ; -1 for stripping final \0.
   500        ))))
   500        ))))
   501 
   501 
   502 (defvar cygwin-mount-table--internal)
   502 (defvar cygwin-mount-table--internal)
   503 (defun my-dos2cygwin-path (path)
   503 (defun my/dos2cygwin-path (path)
   504   "Convert DOS path to Cygwin according to current mount table."
   504   "Convert DOS path to Cygwin according to current mount table."
   505   (interactive (list (read-directory-name "Enter DOS path: ")))
   505   (interactive (list (read-directory-name "Enter DOS path: ")))
   506   (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
   506   (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
   507   (let ( (table cygwin-mount-table--internal) item prefix )
   507   (let ( (table cygwin-mount-table--internal) item prefix )
   508     (while table
   508     (while table
   558   (defun executable-find (command) (locate-file command exec-path exec-suffixes))
   558   (defun executable-find (command) (locate-file command exec-path exec-suffixes))
   559   )
   559   )
   560 
   560 
   561 (ansi-color-for-comint-mode-on)
   561 (ansi-color-for-comint-mode-on)
   562 
   562 
   563 (defun my-ansi-color (&optional beg end)
   563 (defun my/ansi-color (&optional beg end)
   564   "Interpret ANSI color esacape sequence by colorifying cotent.
   564   "Interpret ANSI color esacape sequence by colorifying cotent.
   565 Operate on selected region on whole buffer."
   565 Operate on selected region on whole buffer."
   566   (interactive
   566   (interactive
   567    (if (use-region-p)
   567    (if (use-region-p)
   568        (list (region-beginning) (region-end))
   568        (list (region-beginning) (region-end))
   584 (setq term-scroll-show-maximum-output t)
   584 (setq term-scroll-show-maximum-output t)
   585 
   585 
   586 (my--eval-after-load term
   586 (my--eval-after-load term
   587   (define-key term-mode-map [?\t] #'term-dynamic-complete)
   587   (define-key term-mode-map [?\t] #'term-dynamic-complete)
   588 
   588 
   589   (defun my-term-send-delete-word-forward () (interactive) (term-send-raw-string "\ed"))
   589   (defun my/term-send-delete-word-forward () (interactive) (term-send-raw-string "\ed"))
   590   (defun my-term-send-delete-word-backward () (interactive) (term-send-raw-string "\e\C-h"))
   590   (defun my/term-send-delete-word-backward () (interactive) (term-send-raw-string "\e\C-h"))
   591   (define-key term-raw-map [C-delete] 'my-term-send-delete-word-forward)
   591   (define-key term-raw-map [C-delete] 'my/term-send-delete-word-forward)
   592   (define-key term-raw-map [C-backspace] 'my-term-send-delete-word-backward)
   592   (define-key term-raw-map [C-backspace] 'my/term-send-delete-word-backward)
   593   (defun my-term-send-forward-word () (interactive) (term-send-raw-string "\ef"))
   593   (defun my/term-send-forward-word () (interactive) (term-send-raw-string "\ef"))
   594   (defun my-term-send-backward-word () (interactive) (term-send-raw-string "\eb"))
   594   (defun my/term-send-backward-word () (interactive) (term-send-raw-string "\eb"))
   595   (define-key term-raw-map [C-left] 'my-term-send-backward-word)
   595   (define-key term-raw-map [C-left] 'my/term-send-backward-word)
   596   (define-key term-raw-map [C-right] 'my-term-send-forward-word)
   596   (define-key term-raw-map [C-right] 'my/term-send-forward-word)
   597   (defun my-term-send-m-right () (interactive) (term-send-raw-string "\e[1;3C"))
   597   (defun my/term-send-m-right () (interactive) (term-send-raw-string "\e[1;3C"))
   598   (defun my-term-send-m-left () (interactive) (term-send-raw-string "\e[1;3D"))
   598   (defun my/term-send-m-left () (interactive) (term-send-raw-string "\e[1;3D"))
   599   (define-key term-raw-map [M-right] 'my-term-send-m-right)
   599   (define-key term-raw-map [M-right] 'my/term-send-m-right)
   600   (define-key term-raw-map [M-left] 'my-term-send-m-left) )
   600   (define-key term-raw-map [M-left] 'my/term-send-m-left) )
   601 
   601 
   602 (defun my-term-mode-hook ()
   602 (defun my/term-mode-hook ()
   603   (goto-address-mode 1))
   603   (goto-address-mode 1))
   604 (add-hook 'term-mode-hook #'my-term-mode-hook)
   604 (add-hook 'term-mode-hook #'my/term-mode-hook)
   605 
   605 
   606 (setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
   606 (setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
   607 
   607 
   608 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   608 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   609 (message "proced")
   609 (message "proced")
   619 (setq default-indicate-buffer-boundaries 'left)
   619 (setq default-indicate-buffer-boundaries 'left)
   620 
   620 
   621 ;; (setq-default show-trailing-whitespace t)
   621 ;; (setq-default show-trailing-whitespace t)
   622 
   622 
   623 (setq whitespace-style '(face trailing tabs))
   623 (setq whitespace-style '(face trailing tabs))
   624 (setq whitespace-global-modes (append my-devel-mode-list my-text-mode-list))
   624 (setq whitespace-global-modes (append my/devel-mode-list my/text-mode-list))
   625 (ignore-errors
   625 (ignore-errors
   626   (require 'whitespace)
   626   (require 'whitespace)
   627   (global-whitespace-mode 1))
   627   (global-whitespace-mode 1))
   628 
   628 
   629 (setq next-line-add-newlines nil)
   629 (setq next-line-add-newlines nil)
   719 (setq
   719 (setq
   720  use-dialog-box t
   720  use-dialog-box t
   721  x-gtk-show-hidden-files t
   721  x-gtk-show-hidden-files t
   722  )
   722  )
   723 
   723 
   724 (defun my-prevent-kill-buffer ()
   724 (defun my/prevent-kill-buffer ()
   725   (if (member (buffer-name) '("*scratch*" "NOTE.org")) nil t))
   725   (if (member (buffer-name) '("*scratch*" "NOTE.org")) nil t))
   726 (add-to-list 'kill-buffer-query-functions 'my-prevent-kill-buffer)
   726 (add-to-list 'kill-buffer-query-functions 'my/prevent-kill-buffer)
   727 
   727 
   728 (define-key global-map "\C-v" nil)
   728 (define-key global-map "\C-v" nil)
   729 (define-key global-map "\C-vt" (lambda nil (interactive) (switch-to-buffer "*scratch*")))
   729 (define-key global-map "\C-vt" (lambda nil (interactive) (switch-to-buffer "*scratch*")))
   730 
   730 
   731 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   731 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   732 (message "scrolling")
   732 (message "scrolling")
   733 
   733 
   734 (defvar my-scroll-margin 4)
   734 (defvar my/scroll-margin 4)
   735 
   735 
   736 (setq-default
   736 (setq-default
   737  ;; Set to zero as this recommend documentation.
   737  ;; Set to zero as this recommend documentation.
   738  scroll-step 0
   738  scroll-step 0
   739  ;; If the value is greater than 100, redisplay will never recenter point, but
   739  ;; If the value is greater than 100, redisplay will never recenter point, but
   742  scroll-preserve-screen-position t
   742  scroll-preserve-screen-position t
   743  )
   743  )
   744 
   744 
   745 ;; Set margin only for desired modes! Do not frustrate calendar any more.
   745 ;; Set margin only for desired modes! Do not frustrate calendar any more.
   746 (make-variable-buffer-local 'scroll-margin)
   746 (make-variable-buffer-local 'scroll-margin)
   747 (mapc (lambda (hook) (add-hook hook (lambda nil (setq scroll-margin my-scroll-margin))))
   747 (mapc (lambda (hook) (add-hook hook (lambda nil (setq scroll-margin my/scroll-margin))))
   748       (delete-dups (append my-text-mode-hook-list my-devel-mode-hook-list my-scroll-margin-mode-hook-list)) )
   748       (delete-dups (append my/text-mode-hook-list my/devel-mode-hook-list my/scroll-margin-mode-hook-list)) )
   749 
   749 
   750 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   750 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   751 (message "chars, unicode")
   751 (message "chars, unicode")
   752 
   752 
   753 (defun my-print-unicode (&optional start end)
   753 (defun my/print-unicode (&optional start end)
   754   "Print UNICODE table."
   754   "Print UNICODE table."
   755   (interactive "nstart: \nnend: ")
   755   (interactive "nstart: \nnend: ")
   756   (switch-to-buffer (get-buffer-create "*UNICODE*"))
   756   (switch-to-buffer (get-buffer-create "*UNICODE*"))
   757   (erase-buffer)
   757   (erase-buffer)
   758   (let ( (i start) )
   758   (let ( (i start) )
   815   (interactive)
   815   (interactive)
   816   (let ( (grep-find-template "find . -type f <F> -exec zgrep <C> -nH -e <R> {} +") (grep-find-ignored-files nil) )
   816   (let ( (grep-find-template "find . -type f <F> -exec zgrep <C> -nH -e <R> {} +") (grep-find-ignored-files nil) )
   817     (cl-flet ( (grep-compute-defaults () nil) )
   817     (cl-flet ( (grep-compute-defaults () nil) )
   818       (call-interactively #'rgrep))))
   818       (call-interactively #'rgrep))))
   819 
   819 
       
   820 (ignore-errors (require 'ag))
       
   821 
   820 (defun my/ag (regex)
   822 (defun my/ag (regex)
   821   "Search with ag from project roor without prefix and from
   823   "Search with ag from project roor without prefix and from
   822 `default-directory' with prefix."
   824 `default-directory' with prefix."
   823   (interactive (list (ag/read-from-minibuffer "Search regex")))
   825   (interactive (list (ag/read-from-minibuffer "Search regex")))
   824   (if current-prefix-arg
   826   (if current-prefix-arg
   825       (let ((current-prefix-arg nil)) (ag-regexp regex default-directory))
   827       (let ((current-prefix-arg nil)) (ag-regexp regex default-directory))
   826     (ag-project-regexp regex)))
   828     (ag-project-regexp regex)))
   827 
   829 
   828 (ignore-errors (require 'ag))
       
   829 
       
   830 (setq ag-highlight-search t)
   830 (setq ag-highlight-search t)
   831 (when (featurep 'ag)
   831 (when (featurep 'ag)
   832   (global-set-key [f7] 'my/ag))
   832   (global-set-key [f7] 'my/ag))
   833 
   833 
   834 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   834 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   875 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   875 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   876 (message "highlighting current line")
   876 (message "highlighting current line")
   877 
   877 
   878 (require 'hl-line)
   878 (require 'hl-line)
   879 
   879 
   880 (defun my-hl-line-range-function ()
   880 (defun my/hl-line-range-function ()
   881   (cons (line-end-position) (line-beginning-position 2)))
   881   (cons (line-end-position) (line-beginning-position 2)))
   882 (setq hl-line-range-function #'my-hl-line-range-function)
   882 (setq hl-line-range-function #'my/hl-line-range-function)
   883 
   883 
   884 (set-face-attribute 'hl-line nil :inherit nil :background "light yellow")
   884 (set-face-attribute 'hl-line nil :inherit nil :background "light yellow")
   885 (setq global-hl-line-sticky-flag t)
   885 (setq global-hl-line-sticky-flag t)
   886 (global-hl-line-mode 1)
   886 (global-hl-line-mode 1)
   887 
   887 
   903 ;; cyrillic-jis-russian  for 567 is :,.
   903 ;; cyrillic-jis-russian  for 567 is :,.
   904 ;; cyrillic-jcuken  for SHIFT 567 is :,.
   904 ;; cyrillic-jcuken  for SHIFT 567 is :,.
   905 ;; russian-computer for SHIFT 567 is %^&
   905 ;; russian-computer for SHIFT 567 is %^&
   906 (setq default-input-method 'russian-computer)
   906 (setq default-input-method 'russian-computer)
   907 
   907 
   908 (defun my-toggle-input-method (&optional arg)
   908 (defun my/toggle-input-method (&optional arg)
   909   (interactive "P")
   909   (interactive "P")
   910   (if (numberp arg)
   910   (if (numberp arg)
   911       (cond
   911       (cond
   912        ((eq arg 1)
   912        ((eq arg 1)
   913         (activate-input-method nil))
   913         (activate-input-method nil))
   921         (activate-input-method 'ipa-x-sampa))
   921         (activate-input-method 'ipa-x-sampa))
   922        ((eq arg 6)
   922        ((eq arg 6)
   923         (activate-input-method 'TeX)) )
   923         (activate-input-method 'TeX)) )
   924     (toggle-input-method arg)) )
   924     (toggle-input-method arg)) )
   925 
   925 
   926 (global-set-key (kbd "C-\\") 'my-toggle-input-method)
   926 (global-set-key (kbd "C-\\") 'my/toggle-input-method)
   927 
   927 
   928 ;; I found this more quick method to allow `forward-word' across pronunciation
   928 ;; I found this more quick method to allow `forward-word' across pronunciation
   929 ;; as a whole word.
   929 ;; as a whole word.
   930 (defconst my/ipa-chars (list ?ˈ ?ˌ ?ː ?ǁ ?ʲ ?θ ?ð ?ŋ ?ɡ ?ʒ ?ʃ ?ʧ ?ə ?ɜ ?ɛ ?ʌ ?ɒ ?ɔ ?ɑ ?æ ?ʊ ?ɪ))
   930 (defconst my/ipa-chars (list ?ˈ ?ˌ ?ː ?ǁ ?ʲ ?θ ?ð ?ŋ ?ɡ ?ʒ ?ʃ ?ʧ ?ə ?ɜ ?ɛ ?ʌ ?ɒ ?ɔ ?ɑ ?æ ?ʊ ?ɪ))
   931 (when (boundp 'char-script-table)       ; Absent in Emacs 22.
   931 (when (boundp 'char-script-table)       ; Absent in Emacs 22.
  1127 
  1127 
  1128 (defun my--large-file-p ()
  1128 (defun my--large-file-p ()
  1129   "If buffer too large and my cause performance issue."
  1129   "If buffer too large and my cause performance issue."
  1130   (< large-file-warning-threshold (buffer-size)))
  1130   (< large-file-warning-threshold (buffer-size)))
  1131 
  1131 
  1132 (define-derived-mode my-large-file-mode fundamental-mode "LargeFile"
  1132 (define-derived-mode my/large-file-mode fundamental-mode "LargeFile"
  1133   "Fixes performance issues in Emacs for large files."
  1133   "Fixes performance issues in Emacs for large files."
  1134   ;; (setq buffer-read-only t)
  1134   ;; (setq buffer-read-only t)
  1135   (setq bidi-display-reordering nil)
  1135   (setq bidi-display-reordering nil)
  1136   (jit-lock-mode nil)
  1136   (jit-lock-mode nil)
  1137   (buffer-disable-undo)
  1137   (buffer-disable-undo)
  1139   ;; (setq mode-line-format (delq 'mode-line-position 'mode-line-format))
  1139   ;; (setq mode-line-format (delq 'mode-line-position 'mode-line-format))
  1140   (set (make-local-variable 'global-hl-line-mode) nil)
  1140   (set (make-local-variable 'global-hl-line-mode) nil)
  1141   (set (make-local-variable 'line-number-mode) nil)
  1141   (set (make-local-variable 'line-number-mode) nil)
  1142   (set (make-local-variable 'column-number-mode) nil) )
  1142   (set (make-local-variable 'column-number-mode) nil) )
  1143 
  1143 
  1144 (add-to-list 'magic-mode-alist (cons #'my--large-file-p #'my-large-file-mode))
  1144 (add-to-list 'magic-mode-alist (cons #'my--large-file-p #'my/large-file-mode))
  1145 
  1145 
  1146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1147 (message "helm")
  1147 (message "helm")
  1148 
  1148 
  1149 (eval-when 'compile
  1149 (eval-when 'compile
  1217 ;; dangerous
  1217 ;; dangerous
  1218 ;; (setq
  1218 ;; (setq
  1219 ;;  dired-recursive-copies 'top
  1219 ;;  dired-recursive-copies 'top
  1220 ;;  dired-recursive-deletes 'top)
  1220 ;;  dired-recursive-deletes 'top)
  1221 
  1221 
  1222 (defun my-dired-up-dir ()
  1222 (defun my/dired-up-dir ()
  1223   "'Reuse' buffer if enter to dir or open new buffer if enter to file."
  1223   "'Reuse' buffer if enter to dir or open new buffer if enter to file."
  1224   (interactive)
  1224   (interactive)
  1225   ;; (dired-current-directory) always end with trailing '/' char.
  1225   ;; (dired-current-directory) always end with trailing '/' char.
  1226   (let* ( (dir (dired-current-directory)) (i (- (length dir) 2)) upperdir )
  1226   (let* ( (dir (dired-current-directory)) (i (- (length dir) 2)) upperdir )
  1227     (while (and
  1227     (while (and
  1233     (when (file-directory-p upperdir)
  1233     (when (file-directory-p upperdir)
  1234       (find-alternate-file upperdir)
  1234       (find-alternate-file upperdir)
  1235       (dired-goto-file dir)
  1235       (dired-goto-file dir)
  1236       )
  1236       )
  1237     ))
  1237     ))
  1238 (define-key dired-mode-map (kbd "<backspace>") 'my-dired-up-dir)
  1238 (define-key dired-mode-map (kbd "<backspace>") 'my/dired-up-dir)
  1239 
  1239 
  1240 (defun my-dired-enter-to-dir ()
  1240 (defun my/dired-enter-to-dir ()
  1241   "'Reuse' buffer if enter to dir or open new buffer if enter to file."
  1241   "'Reuse' buffer if enter to dir or open new buffer if enter to file."
  1242   (interactive)
  1242   (interactive)
  1243   (let ( (file (dired-get-file-for-visit)) )
  1243   (let ( (file (dired-get-file-for-visit)) )
  1244     (if (file-directory-p file)
  1244     (if (file-directory-p file)
  1245         (find-alternate-file file)
  1245         (find-alternate-file file)
  1246       (find-file file)
  1246       (find-file file)
  1247       )))
  1247       )))
  1248 (define-key dired-mode-map (kbd "<return>")
  1248 (define-key dired-mode-map (kbd "<return>")
  1249   'my-dired-enter-to-dir)
  1249   'my/dired-enter-to-dir)
  1250 
  1250 
  1251 ;; Make behaviour same as in GUI.
  1251 ;; Make behaviour same as in GUI.
  1252 (unless window-system
  1252 (unless window-system
  1253   (define-key dired-mode-map (kbd "DEL") 'my-dired-up-dir)
  1253   (define-key dired-mode-map (kbd "DEL") 'my/dired-up-dir)
  1254   (define-key dired-mode-map (kbd "RET") 'my-dired-enter-to-dir))
  1254   (define-key dired-mode-map (kbd "RET") 'my/dired-enter-to-dir))
  1255 
  1255 
  1256 ;; Enable 'a' command.
  1256 ;; Enable 'a' command.
  1257 (put 'dired-find-alternate-file 'disabled nil)
  1257 (put 'dired-find-alternate-file 'disabled nil)
  1258 
  1258 
  1259 (defvar my--file-name-tmp-refex
  1259 (defvar my--file-name-tmp-refex
  1324 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1324 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1325 (message "url")
  1325 (message "url")
  1326 
  1326 
  1327 ;; http://tools.ietf.org/html/rfc3986
  1327 ;; http://tools.ietf.org/html/rfc3986
  1328 ;; http://en.wikipedia.org/wiki/Percent-encoding
  1328 ;; http://en.wikipedia.org/wiki/Percent-encoding
  1329 (defun my-percent-decode (str)
  1329 (defun my/percent-decode (str)
  1330   (decode-coding-string
  1330   (decode-coding-string
  1331    (let* ( (s (split-string str "%")) )
  1331    (let* ( (s (split-string str "%")) )
  1332      (my-fold
  1332      (my/fold
  1333       'concat
  1333       'concat
  1334       (car s)
  1334       (car s)
  1335       (mapcar
  1335       (mapcar
  1336        (lambda (x)
  1336        (lambda (x)
  1337          (concat (unibyte-string (string-to-number (substring x 0 2) 16)) (substring x 2)))
  1337          (concat (unibyte-string (string-to-number (substring x 0 2) 16)) (substring x 2)))
  1338        (cdr s))
  1338        (cdr s))
  1339       )) 'utf-8))
  1339       )) 'utf-8))
  1340 
  1340 
  1341 (defun my-percent-decode-region (beg end &optional arg)
  1341 (defun my/percent-decode-region (beg end &optional arg)
  1342   "Convert percent encoded string to native."
  1342   "Convert percent encoded string to native."
  1343   (interactive "r\nP")
  1343   (interactive "r\nP")
  1344   (let ( (result (my-percent-decode (buffer-substring-no-properties beg end))) )
  1344   (let ( (result (my/percent-decode (buffer-substring-no-properties beg end))) )
  1345     (if (not arg)
  1345     (if (not arg)
  1346         result
  1346         result
  1347       (delete-region beg end)
  1347       (delete-region beg end)
  1348       (insert result))
  1348       (insert result))
  1349     ) )
  1349     ) )
  1350 
  1350 
  1351 (defun my-percent-encode (str)
  1351 (defun my/percent-encode (str)
  1352   (apply 'concat
  1352   (apply 'concat
  1353          (mapcar
  1353          (mapcar
  1354           (lambda (ch) (if (or (and (<= ?a ch) (>= ?z ch))
  1354           (lambda (ch) (if (or (and (<= ?a ch) (>= ?z ch))
  1355                           (and (<= ?A ch) (>= ?Z ch))
  1355                           (and (<= ?A ch) (>= ?Z ch))
  1356                           (memq ch '(?- ?_ ?. ?~)))
  1356                           (memq ch '(?- ?_ ?. ?~)))
  1357                       (char-to-string ch)
  1357                       (char-to-string ch)
  1358                     (format "%%%02X" ch)))
  1358                     (format "%%%02X" ch)))
  1359           (encode-coding-string str 'utf-8) )))
  1359           (encode-coding-string str 'utf-8) )))
  1360 
  1360 
  1361 (defun my-percent-encode-region (beg end &optional arg)
  1361 (defun my/percent-encode-region (beg end &optional arg)
  1362   "Encode string to percent encoding."
  1362   "Encode string to percent encoding."
  1363   (interactive "r\nP")
  1363   (interactive "r\nP")
  1364   (let ( (result (my-percent-encode (buffer-substring-no-properties beg end))) )
  1364   (let ( (result (my/percent-encode (buffer-substring-no-properties beg end))) )
  1365     (if (not arg)
  1365     (if (not arg)
  1366         result
  1366         result
  1367       (delete-region beg end)
  1367       (delete-region beg end)
  1368       (insert result))
  1368       (insert result))
  1369     ) )
  1369     ) )
  1377  ((boundp 'debian-emacs-flavor)
  1377  ((boundp 'debian-emacs-flavor)
  1378   (setq browse-url-browser-function 'browse-url-firefox))
  1378   (setq browse-url-browser-function 'browse-url-firefox))
  1379  (t
  1379  (t
  1380   (setq browse-url-browser-function 'browse-url-mozilla)))
  1380   (setq browse-url-browser-function 'browse-url-mozilla)))
  1381 
  1381 
  1382 (defun my-cygwin-search (str)
  1382 (defun my/cygwin-search (str)
  1383   "Search for Cygwin package on-line."
  1383   "Search for Cygwin package on-line."
  1384   (interactive (list (read-string "Search for Cygwin package on-line: ")))
  1384   (interactive (list (read-string "Search for Cygwin package on-line: ")))
  1385   (browse-url (format "http://cygwin.com/cgi-bin2/package-grep.cgi?grep=%s" str))
  1385   (browse-url (format "http://cygwin.com/cgi-bin2/package-grep.cgi?grep=%s" str))
  1386   )
  1386   )
  1387 
  1387 
  1427 (add-hook 'write-file-hooks 'time-stamp)
  1427 (add-hook 'write-file-hooks 'time-stamp)
  1428 
  1428 
  1429 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1429 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1430 (message "logging, logs")
  1430 (message "logging, logs")
  1431 
  1431 
  1432 (defun my-auto-revert-tail-mode-hook ()
  1432 (defun my/auto-revert-tail-mode-hook ()
  1433   (when (string-match "/logs?/\\|\\.\\(?:log\\|out\\)\\'\\|/.xsession-errors\\'"
  1433   (when (string-match "/logs?/\\|\\.\\(?:log\\|out\\)\\'\\|/.xsession-errors\\'"
  1434                       (buffer-file-name (current-buffer)))
  1434                       (buffer-file-name (current-buffer)))
  1435     (auto-revert-tail-mode 1)
  1435     (auto-revert-tail-mode 1)
  1436     (log4-hi-mode 1)
  1436     (log4-hi-mode 1)
  1437     (setq scroll-margin my-scroll-margin)
  1437     (setq scroll-margin my/scroll-margin)
  1438     ))
  1438     ))
  1439 (add-hook 'find-file-hook 'my-auto-revert-tail-mode-hook)
  1439 (add-hook 'find-file-hook 'my/auto-revert-tail-mode-hook)
  1440 
  1440 
  1441 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1441 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1442 (message "auto-fill")
  1442 (message "auto-fill")
  1443 
  1443 
  1444 (setq-default fill-column 78)
  1444 (setq-default fill-column 78)
  1445 
  1445 
  1446 (defvar my-fill-column 100
  1446 (defvar my/fill-column 100
  1447   "I use greater value then 78 for comment in prog source.")
  1447   "I use greater value then 78 for comment in prog source.")
  1448 
  1448 
  1449 ;; By default used American convention - sentence and with two spaces. Change
  1449 ;; By default used American convention - sentence and with two spaces. Change
  1450 ;; it to one space. Has affect on filling and M-a, M-e commands.
  1450 ;; it to one space. Has affect on filling and M-a, M-e commands.
  1451 (setq sentence-end-double-space nil)
  1451 (setq sentence-end-double-space nil)
  1458 (message "cacl, calculator")
  1458 (message "cacl, calculator")
  1459 
  1459 
  1460 (setq-default calc-group-digits t)
  1460 (setq-default calc-group-digits t)
  1461 (setq-default calc-group-char "'")
  1461 (setq-default calc-group-char "'")
  1462 
  1462 
  1463 (defun my-calc-region (arg beg end)
  1463 (defun my/calc-region (arg beg end)
  1464   "Calculate the region and display the result in the echo area.
  1464   "Calculate the region and display the result in the echo area.
  1465 With prefix ARG non-nil, insert the result at the end of region."
  1465 With prefix ARG non-nil, insert the result at the end of region."
  1466   (interactive "P\nr")
  1466   (interactive "P\nr")
  1467   (require 'calc)
  1467   (require 'calc)
  1468   (let* ((expr (buffer-substring-no-properties beg end))
  1468   (let* ((expr (buffer-substring-no-properties beg end))
  1471         (message "%s = %s" expr result)
  1471         (message "%s = %s" expr result)
  1472       (goto-char end)
  1472       (goto-char end)
  1473       (save-excursion
  1473       (save-excursion
  1474         (insert result)))))
  1474         (insert result)))))
  1475 
  1475 
  1476 (defun my-calc-line (arg)
  1476 (defun my/calc-line (arg)
  1477   "Evaluate expression in current line and display the result in
  1477   "Evaluate expression in current line and display the result in
  1478 the echo area by skipping final '=' sign. With prefix ARG
  1478 the echo area by skipping final '=' sign. With prefix ARG
  1479 non-nil, insert the result at the end of line and space if
  1479 non-nil, insert the result at the end of line and space if
  1480 necessary for delimiting."
  1480 necessary for delimiting."
  1481   (interactive "P")
  1481   (interactive "P")
  1602   (let ( (path-separator ":") )
  1602   (let ( (path-separator ":") )
  1603     (require 'info)
  1603     (require 'info)
  1604     (info-initialize) ))
  1604     (info-initialize) ))
  1605 
  1605 
  1606 ;; Info index nodes for automake under Debian.
  1606 ;; Info index nodes for automake under Debian.
  1607 (defvar my-fix-for-automake-info-lookup
  1607 (defvar my/fix-for-automake-info-lookup
  1608   '(("(automake-1.11)Macro Index" nil
  1608   '(("(automake-1.11)Macro Index" nil
  1609      "^`" "['(]")
  1609      "^`" "['(]")
  1610     ("(automake-1.11)Variable Index" nil
  1610     ("(automake-1.11)Variable Index" nil
  1611      "^`" "['(]")
  1611      "^`" "['(]")
  1612     ("(automake-1.11)General Index" nil
  1612     ("(automake-1.11)General Index" nil
  1613      "^`" "['(]")))
  1613      "^`" "['(]")))
  1614 
  1614 
  1615 ;; Add `my-fix-for-automake-info-lookup' entries to the end of doc-spec for
  1615 ;; Add `my/fix-for-automake-info-lookup' entries to the end of doc-spec for
  1616 ;; some modes.
  1616 ;; some modes.
  1617 (my--eval-after-load info-look
  1617 (my--eval-after-load info-look
  1618   (mapc
  1618   (mapc
  1619    (lambda (mode)
  1619    (lambda (mode)
  1620      (let ( (doc-spec (info-lookup->doc-spec 'symbol mode)) )
  1620      (let ( (doc-spec (info-lookup->doc-spec 'symbol mode)) )
  1621        (mapc
  1621        (mapc
  1622         (lambda (doc-spec-item)
  1622         (lambda (doc-spec-item)
  1623           (setcdr (last doc-spec) (list doc-spec-item)))
  1623           (setcdr (last doc-spec) (list doc-spec-item)))
  1624         my-fix-for-automake-info-lookup)))
  1624         my/fix-for-automake-info-lookup)))
  1625    '(makefile-mode autoconf-mode))
  1625    '(makefile-mode autoconf-mode))
  1626   (info-lookup-maybe-add-help
  1626   (info-lookup-maybe-add-help
  1627    :mode 'makefile-gmake-mode
  1627    :mode 'makefile-gmake-mode
  1628    :other-modes '(makefile-mode)))
  1628    :other-modes '(makefile-mode)))
  1629 
  1629 
  1671 (add-hook 'gadict-mode-hook 'whitespace-mode)
  1671 (add-hook 'gadict-mode-hook 'whitespace-mode)
  1672 
  1672 
  1673 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1673 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1674 (message "figlet")
  1674 (message "figlet")
  1675 
  1675 
  1676 (defun my-figlet-region (&optional b e)
  1676 (defun my/figlet-region (&optional b e)
  1677   (interactive "r")
  1677   (interactive "r")
  1678   (shell-command-on-region b e "figlet" (current-buffer) t)
  1678   (shell-command-on-region b e "figlet" (current-buffer) t)
  1679   (comment-region (mark) (point)))
  1679   (comment-region (mark) (point)))
  1680 
  1680 
  1681 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1681 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1814       (apply #'kill-region r))))
  1814       (apply #'kill-region r))))
  1815 
  1815 
  1816 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1816 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1817 (message "TODO, XXX, FIXME highlight")
  1817 (message "TODO, XXX, FIXME highlight")
  1818 
  1818 
  1819 (dolist (mode (append my-devel-mode-list my-text-mode-list))
  1819 (dolist (mode (append my/devel-mode-list my/text-mode-list))
  1820   (font-lock-add-keywords
  1820   (font-lock-add-keywords
  1821    mode
  1821    mode
  1822    `(
  1822    `(
  1823      ( ,(concat "\\<\\(" (regexp-opt '("TODO" "FIX" "FIXME" "HACK" "XXX")) ":?\\)\\>") 1 'font-lock-warning-face t)
  1823      ( ,(concat "\\<\\(" (regexp-opt '("TODO" "FIX" "FIXME" "HACK" "XXX")) ":?\\)\\>") 1 'font-lock-warning-face t)
  1824      ;; 64 times, for highlight C-u C-u C-u <key>
  1824      ;; 64 times, for highlight C-u C-u C-u <key>
  1825      ;; ("\\([^[:space:]]\\)\\1\\{63\\}" 0 'my-contrasty-face t)
  1825      ;; ("\\([^[:space:]]\\)\\1\\{63\\}" 0 'my/contrasty-face t)
  1826      ))
  1826      ))
  1827   )
  1827   )
  1828 
  1828 
  1829 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1829 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1830 (message "mail, message")
  1830 (message "mail, message")
  1831 
  1831 
  1832 (eval-when 'compile (require 'message))
  1832 (eval-when 'compile (require 'message))
  1833 
  1833 
  1834 (setq mail-user-agent 'message-user-agent)
  1834 (setq mail-user-agent 'message-user-agent)
  1835 
  1835 
  1836 (defun my-compose-mail ()
  1836 (defun my/compose-mail ()
  1837   (interactive)
  1837   (interactive)
  1838   (compose-mail nil nil `(("Organization" . ,(getenv "ORGANIZATION")))))
  1838   (compose-mail nil nil `(("Organization" . ,(getenv "ORGANIZATION")))))
  1839 (global-set-key (kbd "C-x m") #'my-compose-mail)
  1839 (global-set-key (kbd "C-x m") #'my/compose-mail)
  1840 
  1840 
  1841 (setq message-citation-line-format "On %Y-%m-%d, %N wrote:
  1841 (setq message-citation-line-format "On %Y-%m-%d, %N wrote:
  1842 ")
  1842 ")
  1843 (setq message-citation-line-function 'message-insert-formatted-citation-line)
  1843 (setq message-citation-line-function 'message-insert-formatted-citation-line)
  1844 
  1844 
  1856 
  1856 
  1857 (my--eval-after-load message
  1857 (my--eval-after-load message
  1858   (require 'mailabbrev)
  1858   (require 'mailabbrev)
  1859   (define-key message-mode-map "\e\t" 'mail-abbrev-complete-alias))
  1859   (define-key message-mode-map "\e\t" 'mail-abbrev-complete-alias))
  1860 
  1860 
  1861 (defun my-message-mode-hook ()
  1861 (defun my/message-mode-hook ()
  1862   (setq fill-column 78)
  1862   (setq fill-column 78)
  1863   (turn-on-auto-fill)
  1863   (turn-on-auto-fill)
  1864   (flyspell-mode 1))
  1864   (flyspell-mode 1))
  1865 (add-hook 'message-mode-hook 'my-message-mode-hook)
  1865 (add-hook 'message-mode-hook 'my/message-mode-hook)
  1866 
  1866 
  1867 ;; Mark all my messages by "common" string in "Message-Id" field to simplify
  1867 ;; Mark all my messages by "common" string in "Message-Id" field to simplify
  1868 ;; lookup for followups to me.
  1868 ;; lookup for followups to me.
  1869 (setq message-user-fqdn "gavenkoa.example.com")
  1869 (setq message-user-fqdn "gavenkoa.example.com")
  1870 
  1870 
  1939  gnus-backup-startup-file t
  1939  gnus-backup-startup-file t
  1940  gnus-use-dribble-file t
  1940  gnus-use-dribble-file t
  1941  gnus-save-killed-list t
  1941  gnus-save-killed-list t
  1942  )
  1942  )
  1943 
  1943 
  1944 (defun my-kill-gnus ()
  1944 (defun my/kill-gnus ()
  1945   "Kill Gnus when exiting Emacs."
  1945   "Kill Gnus when exiting Emacs."
  1946   (let ( (gnus-interactive-exit nil) )
  1946   (let ( (gnus-interactive-exit nil) )
  1947     (gnus-group-exit)
  1947     (gnus-group-exit)
  1948     ))
  1948     ))
  1949 (my--eval-after-load gnus
  1949 (my--eval-after-load gnus
  1950   (add-hook 'kill-emacs-hook 'my-kill-gnus))
  1950   (add-hook 'kill-emacs-hook 'my/kill-gnus))
  1951 
  1951 
  1952 (my--eval-after-load gnus-art
  1952 (my--eval-after-load gnus-art
  1953   (setq gnus-visible-headers (concat gnus-visible-headers "\\|^Archived-At:\\|^List-URL:\\|^Message-Id:")))
  1953   (setq gnus-visible-headers (concat gnus-visible-headers "\\|^Archived-At:\\|^List-URL:\\|^Message-Id:")))
  1954 
  1954 
  1955 ;; Store gnus specific files to '~/.gnus'.
  1955 ;; Store gnus specific files to '~/.gnus'.
  2025 (eval-when-compile
  2025 (eval-when-compile
  2026   (ignore-errors
  2026   (ignore-errors
  2027     ;; w3m-anchor is macros in newer Emacs, need definition during byte-compilation.
  2027     ;; w3m-anchor is macros in newer Emacs, need definition during byte-compilation.
  2028     (require 'w3m-util)))
  2028     (require 'w3m-util)))
  2029 
  2029 
  2030 (defun my-w3m-view-url ()
  2030 (defun my/w3m-view-url ()
  2031   (interactive)
  2031   (interactive)
  2032   (browse-url (w3m-anchor)))
  2032   (browse-url (w3m-anchor)))
  2033 
  2033 
  2034 (my--eval-after-load w3m
  2034 (my--eval-after-load w3m
  2035   (define-key w3m-minor-mode-map (kbd "RET") #'my-w3m-view-url)
  2035   (define-key w3m-minor-mode-map (kbd "RET") #'my/w3m-view-url)
  2036   (define-key w3m-minor-mode-map (kbd "S-RET") #'w3m-safe-view-this-url)
  2036   (define-key w3m-minor-mode-map (kbd "S-RET") #'w3m-safe-view-this-url)
  2037   (define-key w3m-minor-mode-map (kbd "<left>") #'backward-char)
  2037   (define-key w3m-minor-mode-map (kbd "<left>") #'backward-char)
  2038   (define-key w3m-minor-mode-map (kbd "<right>") #'forward-char)
  2038   (define-key w3m-minor-mode-map (kbd "<right>") #'forward-char)
  2039   (define-key w3m-minor-mode-map (kbd "<up>") #'previous-line)
  2039   (define-key w3m-minor-mode-map (kbd "<up>") #'previous-line)
  2040   (define-key w3m-minor-mode-map (kbd "<down>") #'next-line))
  2040   (define-key w3m-minor-mode-map (kbd "<down>") #'next-line))
  2157 ;; Increase the score for followups to a sent article.
  2157 ;; Increase the score for followups to a sent article.
  2158 (my--eval-after-load gnus-score
  2158 (my--eval-after-load gnus-score
  2159   ;; (add-hook 'message-sent-hook 'gnus-score-followup-article)
  2159   ;; (add-hook 'message-sent-hook 'gnus-score-followup-article)
  2160   (add-hook 'message-sent-hook 'gnus-score-followup-thread))
  2160   (add-hook 'message-sent-hook 'gnus-score-followup-thread))
  2161 
  2161 
  2162 (defvar my-gnus-summary-kill-same-subject-min-len 8
  2162 (defvar my/gnus-summary-kill-same-subject-min-len 8
  2163   "Minimal length of subject string to ignore this subject.")
  2163   "Minimal length of subject string to ignore this subject.")
  2164 (defun my-gnus-summary-kill-same-subject (&optional unmark)
  2164 (defun my/gnus-summary-kill-same-subject (&optional unmark)
  2165   "Add negative scores for all articles with same subject."
  2165   "Add negative scores for all articles with same subject."
  2166   (interactive "P")
  2166   (interactive "P")
  2167   (when (or (not (integerp unmark)) (< 0 unmark))
  2167   (when (or (not (integerp unmark)) (< 0 unmark))
  2168     (let ( (subj (gnus-simplify-subject-fuzzy (gnus-summary-article-subject))) )
  2168     (let ( (subj (gnus-simplify-subject-fuzzy (gnus-summary-article-subject))) )
  2169       (when (<= (length subj) my-gnus-summary-kill-same-subject-min-len)
  2169       (when (<= (length subj) my/gnus-summary-kill-same-subject-min-len)
  2170         (gnus-summary-score-entry
  2170         (gnus-summary-score-entry
  2171          "subject" subj
  2171          "subject" subj
  2172          's (- gnus-score-interactive-default-score) (current-time-string)))))
  2172          's (- gnus-score-interactive-default-score) (current-time-string)))))
  2173   (gnus-summary-kill-same-subject unmark))
  2173   (gnus-summary-kill-same-subject unmark))
  2174 (my--eval-after-load gnus-sum
  2174 (my--eval-after-load gnus-sum
  2175   (define-key gnus-summary-mode-map (kbd "C-k") #'my-gnus-summary-kill-same-subject))
  2175   (define-key gnus-summary-mode-map (kbd "C-k") #'my/gnus-summary-kill-same-subject))
  2176 
  2176 
  2177 (defun my/gnus-mark-thread-as-read ()
  2177 (defun my/gnus-mark-thread-as-read ()
  2178   "Mark unmarked articles in current thread as read and move to
  2178   "Mark unmarked articles in current thread as read and move to
  2179 next thread without selecting article."
  2179 next thread without selecting article."
  2180   (interactive)
  2180   (interactive)
  2186       (when (or (not (gnus-summary-search-forward)) (eq (gnus-summary-thread-level) 0))
  2186       (when (or (not (gnus-summary-search-forward)) (eq (gnus-summary-thread-level) 0))
  2187         (throw 'exit nil)) )))
  2187         (throw 'exit nil)) )))
  2188 (my--eval-after-load gnus-sum
  2188 (my--eval-after-load gnus-sum
  2189   (define-key gnus-summary-mode-map (kbd "H-k") #'my/gnus-mark-thread-as-read))
  2189   (define-key gnus-summary-mode-map (kbd "H-k") #'my/gnus-mark-thread-as-read))
  2190 
  2190 
  2191 (defun my-gnus-thread-score-function (&rest scores)
  2191 (defun my/gnus-thread-score-function (&rest scores)
  2192   "If any followup have positive score assign greater available
  2192   "If any followup have positive score assign greater available
  2193 score to thread, else assign lesser available score."
  2193 score to thread, else assign lesser available score."
  2194   (let ( (max (apply 'max scores)) (min (apply 'min scores)) )
  2194   (let ( (max (apply 'max scores)) (min (apply 'min scores)) )
  2195     (if (< 0 max) max min)))
  2195     (if (< 0 max) max min)))
  2196 (setq gnus-thread-score-function #'my-gnus-thread-score-function)
  2196 (setq gnus-thread-score-function #'my/gnus-thread-score-function)
  2197 (defun my-gnus-thread-total-score ()
  2197 (defun my/gnus-thread-total-score ()
  2198   "Helper to debug `gnus-thread-score-function' function."
  2198   "Helper to debug `gnus-thread-score-function' function."
  2199   (interactive)
  2199   (interactive)
  2200   (message
  2200   (message
  2201    (int-to-string
  2201    (int-to-string
  2202     (gnus-thread-total-score
  2202     (gnus-thread-total-score
  2293   (when (featurep 'fsm)
  2293   (when (featurep 'fsm)
  2294     (setq fsm-debug nil))               ; Disable *fsm-debug* buffer.
  2294     (setq fsm-debug nil))               ; Disable *fsm-debug* buffer.
  2295   ;; Handle Emacs exit.
  2295   ;; Handle Emacs exit.
  2296   (add-hook 'kill-emacs-hook 'jabber-disconnect))
  2296   (add-hook 'kill-emacs-hook 'jabber-disconnect))
  2297 
  2297 
  2298 (defvar my-chat-prompt "[%t] %n>\n")
  2298 (defvar my/chat-prompt "[%t] %n>\n")
  2299 (setq
  2299 (setq
  2300  jabber-chat-foreign-prompt-format my-chat-prompt
  2300  jabber-chat-foreign-prompt-format my/chat-prompt
  2301  jabber-chat-local-prompt-format my-chat-prompt
  2301  jabber-chat-local-prompt-format my/chat-prompt
  2302  jabber-groupchat-prompt-format my-chat-prompt
  2302  jabber-groupchat-prompt-format my/chat-prompt
  2303  jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n")
  2303  jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n")
  2304 
  2304 
  2305 (let ( (mgs-list '("Я тутачки, а где Вы меня ожидали?"
  2305 (let ( (mgs-list '("Я тутачки, а где Вы меня ожидали?"
  2306                    "Software Development == Church Development. Step 1. Build it. Step 2. Pray."
  2306                    "Software Development == Church Development. Step 1. Build it. Step 2. Pray."
  2307                    "Great books aren't written – they're rewritten."
  2307                    "Great books aren't written – they're rewritten."
  2309   (random t)
  2309   (random t)
  2310   (setq jabber-default-show (nth (random (length mgs-list)) mgs-list))
  2310   (setq jabber-default-show (nth (random (length mgs-list)) mgs-list))
  2311   (setq jabber-default-status (nth (random (length mgs-list)) mgs-list))
  2311   (setq jabber-default-status (nth (random (length mgs-list)) mgs-list))
  2312   )
  2312   )
  2313 
  2313 
  2314 (defvar my-jabber-users nil
  2314 (defvar my/jabber-users nil
  2315   "Assoc list of jabber user group. Keys are strings, values are lists of JIDs.")
  2315   "Assoc list of jabber user group. Keys are strings, values are lists of JIDs.")
  2316 
  2316 
  2317 (defun my-jabber-send (group)
  2317 (defun my/jabber-send (group)
  2318   "GROUP is keys from `my-jabber-users'"
  2318   "GROUP is keys from `my/jabber-users'"
  2319   (interactive
  2319   (interactive
  2320    (list (completing-read "Select group: " my-jabber-users))
  2320    (list (completing-read "Select group: " my/jabber-users))
  2321    )
  2321    )
  2322   (let (
  2322   (let (
  2323         (msg (if (use-region-p)
  2323         (msg (if (use-region-p)
  2324                  (buffer-substring (region-beginning) (region-end))
  2324                  (buffer-substring (region-beginning) (region-end))
  2325                (buffer-string)))
  2325                (buffer-string)))
  2328     (deactivate-mark)
  2328     (deactivate-mark)
  2329     (mapc
  2329     (mapc
  2330      (lambda (user)
  2330      (lambda (user)
  2331        (jabber-send-message jc user "" msg "normal")
  2331        (jabber-send-message jc user "" msg "normal")
  2332        )
  2332        )
  2333      (cdr (assoc group my-jabber-users))
  2333      (cdr (assoc group my/jabber-users))
  2334      )
  2334      )
  2335     )
  2335     )
  2336   )
  2336   )
  2337 
  2337 
  2338 (global-set-key (kbd "C-x C-j C-s") 'my-jabber-send)
  2338 (global-set-key (kbd "C-x C-j C-s") 'my/jabber-send)
  2339 
  2339 
  2340 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2340 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2341 (message "erc")
  2341 (message "erc")
  2342 
  2342 
  2343 (eval-when 'compile
  2343 (eval-when 'compile
  2398 
  2398 
  2399 (add-to-list 'magic-mode-alist '(my--c++-header-file-p . c++-mode))
  2399 (add-to-list 'magic-mode-alist '(my--c++-header-file-p . c++-mode))
  2400 
  2400 
  2401 (setq-default comment-style (quote indent))
  2401 (setq-default comment-style (quote indent))
  2402 (setq-default comment-column 44)
  2402 (setq-default comment-column 44)
  2403 (setq-default comment-fill-column my-fill-column)
  2403 (setq-default comment-fill-column my/fill-column)
  2404 
  2404 
  2405 (mapc (lambda (hook) (add-hook hook (lambda () (setq fill-column my-fill-column)) ))
  2405 (mapc (lambda (hook) (add-hook hook (lambda () (setq fill-column my/fill-column)) ))
  2406       (append my-devel-mode-hook-list my-text-mode-hook-list))
  2406       (append my/devel-mode-hook-list my/text-mode-hook-list))
  2407 
  2407 
  2408 (mapc (lambda (mode) (add-hook (my-mode2hook mode) #'hs-minor-mode))
  2408 (mapc (lambda (mode) (add-hook (my/mode2hook mode) #'hs-minor-mode))
  2409       '(c-mode c++-mode java-mode js-mode lisp-mode emacs-lisp-mode))
  2409       '(c-mode c++-mode java-mode js-mode lisp-mode emacs-lisp-mode))
  2410 
  2410 
  2411 (defun my/company-prog-mode-setup ()
  2411 (defun my/company-prog-mode-setup ()
  2412   (setq-local company-dabbrev-code-other-buffers 'code)
  2412   (setq-local company-dabbrev-code-other-buffers 'code)
  2413   (setq-local company-backends '((company-capf company-dabbrev-code company-files)))
  2413   (setq-local company-backends '((company-capf company-dabbrev-code company-files)))
  2428 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
  2428 (setq ediff-window-setup-function 'ediff-setup-windows-plain)
  2429 (setq ediff-split-window-function 'split-window-vertically)
  2429 (setq ediff-split-window-function 'split-window-vertically)
  2430 
  2430 
  2431 ;; Disable: sometimes it take a long time to process large hunks.
  2431 ;; Disable: sometimes it take a long time to process large hunks.
  2432 ;; Use C-c C-b on hunk by own.
  2432 ;; Use C-c C-b on hunk by own.
  2433 ;; (defun my-diff-auto-refine-mode-on () (diff-auto-refine-mode 1))
  2433 ;; (defun my/diff-auto-refine-mode-on () (diff-auto-refine-mode 1))
  2434 ;; (add-hook 'diff-mode-hook 'my-diff-auto-refine-mode-on)
  2434 ;; (add-hook 'diff-mode-hook 'my/diff-auto-refine-mode-on)
  2435 
  2435 
  2436 (when window-system
  2436 (when window-system
  2437   (my--eval-after-load diff-mode
  2437   (my--eval-after-load diff-mode
  2438     (set-face-foreground 'diff-added-face "DarkGreen")
  2438     (set-face-foreground 'diff-added-face "DarkGreen")
  2439     (set-face-foreground 'diff-removed-face "DarkRed")
  2439     (set-face-foreground 'diff-removed-face "DarkRed")
  2448 
  2448 
  2449 ;; `-b' switch to ignore changes in whitespaces.
  2449 ;; `-b' switch to ignore changes in whitespaces.
  2450 ;; (setq vc-git-diff-switches "-b")
  2450 ;; (setq vc-git-diff-switches "-b")
  2451 ;; (setq vc-diff-switches "-b")
  2451 ;; (setq vc-diff-switches "-b")
  2452 
  2452 
  2453 (defun my-vc-root-diff (prefix)
  2453 (defun my/vc-root-diff (prefix)
  2454   "Same as `vc-root-diff' but for Hg with C-u show latest MQ patch and
  2454   "Same as `vc-root-diff' but for Hg with C-u show latest MQ patch and
  2455 with C-u C-u show MQ patch and local changes."
  2455 with C-u C-u show MQ patch and local changes."
  2456   (interactive "P")
  2456   (interactive "P")
  2457   (when (eq 'non-hg-mq
  2457   (when (eq 'non-hg-mq
  2458             (catch 'break
  2458             (catch 'break
  2466                   (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" "qtip"))
  2466                   (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" "qtip"))
  2467                  ((equal prefix '(16))
  2467                  ((equal prefix '(16))
  2468                   (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" nil)) ))))
  2468                   (vc-diff-internal t (list 'Hg (list rootdir)) "qparent" nil)) ))))
  2469     (call-interactively 'vc-root-diff nil) ))
  2469     (call-interactively 'vc-root-diff nil) ))
  2470 
  2470 
  2471 (global-set-key (kbd "C-x v D") 'my-vc-root-diff)
  2471 (global-set-key (kbd "C-x v D") 'my/vc-root-diff)
  2472 
  2472 
  2473 (when window-system
  2473 (when window-system
  2474   (setq
  2474   (setq
  2475    vc-annotate-very-old-color "#0b5b20"
  2475    vc-annotate-very-old-color "#0b5b20"
  2476    vc-annotate-background "white"
  2476    vc-annotate-background "white"
  2494      (320 . "#2780C6")
  2494      (320 . "#2780C6")
  2495      (340 . "#1A00D3")
  2495      (340 . "#1A00D3")
  2496      (360 . "#0D80E0")))
  2496      (360 . "#0D80E0")))
  2497   )
  2497   )
  2498 
  2498 
  2499 (defun my-log-edit-mode-hook ()
  2499 (defun my/log-edit-mode-hook ()
  2500   (setq fill-column 78)
  2500   (setq fill-column 78)
  2501   )
  2501   )
  2502 (add-hook 'log-edit-mode-hook 'my-log-edit-mode-hook t)
  2502 (add-hook 'log-edit-mode-hook 'my/log-edit-mode-hook t)
  2503 
  2503 
  2504 (eval-after-load 'log-edit
  2504 (eval-after-load 'log-edit
  2505   '(remove-hook 'log-edit-hook 'log-edit-insert-message-template))
  2505   '(remove-hook 'log-edit-hook 'log-edit-insert-message-template))
  2506 
  2506 
  2507 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2507 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2556     (add-to-list 'compilation-mode-font-lock-keywords '("\\(/[Oo][Uu][Tt]:[^[:blank:]]+\\)" . 1))
  2556     (add-to-list 'compilation-mode-font-lock-keywords '("\\(/[Oo][Uu][Tt]:[^[:blank:]]+\\)" . 1))
  2557     (add-to-list 'compilation-mode-font-lock-keywords '("[[:blank:]]\\(/F[oe][^[:blank:]]+\\)" . 1))))
  2557     (add-to-list 'compilation-mode-font-lock-keywords '("[[:blank:]]\\(/F[oe][^[:blank:]]+\\)" . 1))))
  2558 
  2558 
  2559 (ignore-errors
  2559 (ignore-errors
  2560   (require 'ansi-color)
  2560   (require 'ansi-color)
  2561   (defun my-colorize-compilation-buffer ()
  2561   (defun my/colorize-compilation-buffer ()
  2562     (when (eq major-mode 'compilation-mode)
  2562     (when (eq major-mode 'compilation-mode)
  2563       (ansi-color-apply-on-region compilation-filter-start (point-max))))
  2563       (ansi-color-apply-on-region compilation-filter-start (point-max))))
  2564   (add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))
  2564   (add-hook 'compilation-filter-hook 'my/colorize-compilation-buffer))
  2565 
  2565 
  2566 (defvar my-comint-send-hist-list nil
  2566 (defvar my/comint-send-hist-list nil
  2567   "History list for `my-comint-send-string'."
  2567   "History list for `my/comint-send-string'."
  2568   )
  2568   )
  2569 (defun my-comint-send-string (string)
  2569 (defun my/comint-send-string (string)
  2570   "Send string to comint buffers. Useful for *compilation* read-only buffer.
  2570   "Send string to comint buffers. Useful for *compilation* read-only buffer.
  2571 Automaticaly append final newline."
  2571 Automaticaly append final newline."
  2572   (interactive
  2572   (interactive
  2573    (list (read-string "Type string: " nil 'my-comint-send-hist-list))
  2573    (list (read-string "Type string: " nil 'my/comint-send-hist-list))
  2574    )
  2574    )
  2575   (comint-send-string (get-buffer-process (current-buffer)) (concat string "\n"))
  2575   (comint-send-string (get-buffer-process (current-buffer)) (concat string "\n"))
  2576   )
  2576   )
  2577 (my--eval-after-load compile
  2577 (my--eval-after-load compile
  2578   (define-key compilation-mode-map [C-return] 'my-comint-send-string))
  2578   (define-key compilation-mode-map [C-return] 'my/comint-send-string))
  2579 
  2579 
  2580 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2580 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2581 (message "scons")
  2581 (message "scons")
  2582 
  2582 
  2583 (add-to-list 'auto-mode-alist '("SConstruct\\'" . python-mode))
  2583 (add-to-list 'auto-mode-alist '("SConstruct\\'" . python-mode))
  2616   (global-set-key "\M-." 'etags-select-find-tag)
  2616   (global-set-key "\M-." 'etags-select-find-tag)
  2617   )
  2617   )
  2618 
  2618 
  2619 (setq tags-add-tables t)
  2619 (setq tags-add-tables t)
  2620 
  2620 
  2621 (defvar my-ido-tag-history nil
  2621 (defvar my/ido-tag-history nil
  2622   "History of tags selected using `my-ido-complete-tag'.")
  2622   "History of tags selected using `my/ido-complete-tag'.")
  2623 (defun my-ido-complete-tag (&optional substr)
  2623 (defun my/ido-complete-tag (&optional substr)
  2624   "Find a tag using ido."
  2624   "Find a tag using ido."
  2625   (tags-completion-table)
  2625   (tags-completion-table)
  2626   (let ( tag-names )
  2626   (let ( tag-names )
  2627     (mapatoms (lambda (x) (push (symbol-name x) tag-names)) tags-completion-table)
  2627     (mapatoms (lambda (x) (push (symbol-name x) tag-names)) tags-completion-table)
  2628     (ido-completing-read "Tag: " tag-names nil t substr 'my-ido-tag-history)))
  2628     (ido-completing-read "Tag: " tag-names nil t substr 'my/ido-tag-history)))
  2629 (defun my-complete-tag (prefix point)
  2629 (defun my/complete-tag (prefix point)
  2630   (interactive "P\nd")
  2630   (interactive "P\nd")
  2631   (if prefix
  2631   (if prefix
  2632       (funcall #'complete-tag)
  2632       (funcall #'complete-tag)
  2633     (let ( (bounds (find-tag-default-bounds)) tag )
  2633     (let ( (bounds (find-tag-default-bounds)) tag )
  2634       (if (or (not bounds) (< point (car bounds)) (< (cdr bounds) point))
  2634       (if (or (not bounds) (< point (car bounds)) (< (cdr bounds) point))
  2635           (setq tag (my-ido-complete-tag))
  2635           (setq tag (my/ido-complete-tag))
  2636         (setq tag (my-ido-complete-tag (buffer-substring (car bounds) (cdr bounds))))
  2636         (setq tag (my/ido-complete-tag (buffer-substring (car bounds) (cdr bounds))))
  2637         (delete-region (car bounds) (cdr bounds)))
  2637         (delete-region (car bounds) (cdr bounds)))
  2638       (insert tag))))
  2638       (insert tag))))
  2639 
  2639 
  2640 (global-set-key [M-return] #'my-complete-tag)
  2640 (global-set-key [M-return] #'my/complete-tag)
  2641 
  2641 
  2642 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2642 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2643 (message "CEDET, semantic, SRecord")
  2643 (message "CEDET, semantic, SRecord")
  2644 
  2644 
  2645 ;; For debug use 'semantic-debug-idle-function' and 'semantic-debug-idle-work-function'.
  2645 ;; For debug use 'semantic-debug-idle-function' and 'semantic-debug-idle-work-function'.
  2696   (defvar srecode-map-load-path nil)
  2696   (defvar srecode-map-load-path nil)
  2697   (add-to-list 'srecode-map-load-path (locate-user-emacs-file "srecode/"))
  2697   (add-to-list 'srecode-map-load-path (locate-user-emacs-file "srecode/"))
  2698   (global-srecode-minor-mode 1)
  2698   (global-srecode-minor-mode 1)
  2699   (add-hook 'prog-mode-hook 'srecode-minor-mode)
  2699   (add-hook 'prog-mode-hook 'srecode-minor-mode)
  2700 
  2700 
  2701   (defun my-srecode-reload-templates ()
  2701   (defun my/srecode-reload-templates ()
  2702     "Reload all templates under `srecode-map-load-path'. Useful
  2702     "Reload all templates under `srecode-map-load-path'. Useful
  2703 during template developing."
  2703 during template developing."
  2704     (interactive)
  2704     (interactive)
  2705     (setq srecode-mode-table-list nil
  2705     (setq srecode-mode-table-list nil
  2706           srecode-current-map nil)
  2706           srecode-current-map nil)
  2726   ;; (add-to-list 'ede-locate-setup-options 'ede-locate-idutils)
  2726   ;; (add-to-list 'ede-locate-setup-options 'ede-locate-idutils)
  2727   ;; (add-to-list 'ede-locate-setup-options 'ede-locate-global)
  2727   ;; (add-to-list 'ede-locate-setup-options 'ede-locate-global)
  2728 
  2728 
  2729   ;; (ignore-errors (require 'cedet-idutils))
  2729   ;; (ignore-errors (require 'cedet-idutils))
  2730 
  2730 
  2731   (defun my-c-mode-cedet-hook ()
  2731   (defun my/c-mode-cedet-hook ()
  2732     ;; (local-set-key [C-return] 'semantic-complete-symbol)
  2732     ;; (local-set-key [C-return] 'semantic-complete-symbol)
  2733     ;; (local-set-key [C-return] 'semantic-complete-analyze-inline)
  2733     ;; (local-set-key [C-return] 'semantic-complete-analyze-inline)
  2734     ;; (local-set-key "." 'semantic-complete-self-insert)
  2734     ;; (local-set-key "." 'semantic-complete-self-insert)
  2735     ;; (local-set-key ">" 'semantic-complete-self-insert)
  2735     ;; (local-set-key ">" 'semantic-complete-self-insert)
  2736     )
  2736     )
  2737   (add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
  2737   (add-hook 'c-mode-common-hook 'my/c-mode-cedet-hook)
  2738 
  2738 
  2739   (ignore-errors
  2739   (ignore-errors
  2740     (require 'semantic/ia)
  2740     (require 'semantic/ia)
  2741     (define-key semantic-mode-map (kbd "C-c , .") 'semantic-ia-fast-jump)
  2741     (define-key semantic-mode-map (kbd "C-c , .") 'semantic-ia-fast-jump)
  2742     (define-key semantic-mode-map (kbd "C-c , d") 'semantic-ia-show-doc)
  2742     (define-key semantic-mode-map (kbd "C-c , d") 'semantic-ia-show-doc)
  2754 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2754 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2755 (message "imenu")
  2755 (message "imenu")
  2756 
  2756 
  2757 (require 'imenu)
  2757 (require 'imenu)
  2758 
  2758 
  2759 (defun my-imenu-to-menubar ()
  2759 (defun my/imenu-to-menubar ()
  2760   "Force imenu building when (menu-bar-mode -1)."
  2760   "Force imenu building when (menu-bar-mode -1)."
  2761   (when imenu-generic-expression
  2761   (when imenu-generic-expression
  2762     (imenu-add-menubar-index)
  2762     (imenu-add-menubar-index)
  2763     (run-hooks 'menu-bar-update-hook) ))
  2763     (run-hooks 'menu-bar-update-hook) ))
  2764 (mapc (lambda (hook) (add-hook hook 'my-imenu-to-menubar))
  2764 (mapc (lambda (hook) (add-hook hook 'my/imenu-to-menubar))
  2765       my-devel-mode-hook-list)
  2765       my/devel-mode-hook-list)
  2766 
  2766 
  2767 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2767 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2768 (message "windows inf files for driver installin")
  2768 (message "windows inf files for driver installin")
  2769 
  2769 
  2770 (add-to-list 'auto-mode-alist '("\\.inf\\'" . conf-mode))
  2770 (add-to-list 'auto-mode-alist '("\\.inf\\'" . conf-mode))
  2823 ;; Minor mode that highlights suspicious C and C++ constructions.
  2823 ;; Minor mode that highlights suspicious C and C++ constructions.
  2824 (global-cwarn-mode 1)
  2824 (global-cwarn-mode 1)
  2825 
  2825 
  2826 (setq c-echo-syntactic-information-p t)
  2826 (setq c-echo-syntactic-information-p t)
  2827 
  2827 
  2828 (defun my-c-mode-common-hook ()
  2828 (defun my/c-mode-common-hook ()
  2829   ;; Automatically inserte newlines after special characters such as brace, comma, semi-colon, and colon.
  2829   ;; Automatically inserte newlines after special characters such as brace, comma, semi-colon, and colon.
  2830   (c-toggle-auto-newline -1)
  2830   (c-toggle-auto-newline -1)
  2831   ;; Delete all preceding whitespace by DEL.
  2831   ;; Delete all preceding whitespace by DEL.
  2832   (c-toggle-hungry-state -1)
  2832   (c-toggle-hungry-state -1)
  2833   ;; Auto indent after typing colon according to `c-hanging-colons-alist'.
  2833   ;; Auto indent after typing colon according to `c-hanging-colons-alist'.
  2834   (c-toggle-electric-state 1)
  2834   (c-toggle-electric-state 1)
  2835   )
  2835   )
  2836 (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
  2836 (add-hook 'c-mode-common-hook 'my/c-mode-common-hook)
  2837 
  2837 
  2838 (defconst my-c-style
  2838 (defconst my/c-style
  2839   '((c-tab-always-indent . t)
  2839   '((c-tab-always-indent . t)
  2840     (c-comment-only-line-offset . 4)
  2840     (c-comment-only-line-offset . 4)
  2841     (c-hanging-braces-alist
  2841     (c-hanging-braces-alist
  2842      . (
  2842      . (
  2843         (brace-list-open)
  2843         (brace-list-open)
  2881     (c-report-syntactic-errors . t)
  2881     (c-report-syntactic-errors . t)
  2882     ;; Echo syntactic information on TAB in message buffer.
  2882     ;; Echo syntactic information on TAB in message buffer.
  2883     (c-echo-syntactic-information-p . t))
  2883     (c-echo-syntactic-information-p . t))
  2884   "My C Programming Style")
  2884   "My C Programming Style")
  2885 
  2885 
  2886 (defun my-c-mode-style-hook ()
  2886 (defun my/c-mode-style-hook ()
  2887   (c-add-style "my" my-c-style t)
  2887   (c-add-style "my" my/c-style t)
  2888   ;; If set 'c-default-style' before 'c-add-style'
  2888   ;; If set 'c-default-style' before 'c-add-style'
  2889   ;; "Undefined style: my" error occured from 'c-get-style-variables'.
  2889   ;; "Undefined style: my" error occured from 'c-get-style-variables'.
  2890   (setq c-default-style
  2890   (setq c-default-style
  2891         '(
  2891         '(
  2892           (java-mode . "my") (c-mode . "my") (csharp-mode . "my") (c++-mode . "my") (objc-mode . "my")
  2892           (java-mode . "my") (c-mode . "my") (csharp-mode . "my") (c++-mode . "my") (objc-mode . "my")
  2893           (idl-mode . "my")
  2893           (idl-mode . "my")
  2894           (awk-mode . "awk")
  2894           (awk-mode . "awk")
  2895           (other . "my")
  2895           (other . "my")
  2896           ))
  2896           ))
  2897   )
  2897   )
  2898 (add-hook 'c-mode-common-hook 'my-c-mode-style-hook)
  2898 (add-hook 'c-mode-common-hook 'my/c-mode-style-hook)
  2899 
  2899 
  2900 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2900 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2901 (message "python, python-mode")
  2901 (message "python, python-mode")
  2902 
  2902 
  2903 (eval-when 'compile
  2903 (eval-when 'compile
  3083   ;; (pymacs-load "ropemacs" "rope-")
  3083   ;; (pymacs-load "ropemacs" "rope-")
  3084   )
  3084   )
  3085 ;; Automatically save project python buffers before refactorings
  3085 ;; Automatically save project python buffers before refactorings
  3086 (setq ropemacs-confirm-saving 'nil)
  3086 (setq ropemacs-confirm-saving 'nil)
  3087 
  3087 
  3088 (defun my-python-add-to-path (path)
  3088 (defun my/python-add-to-path (path)
  3089   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
  3089   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
  3090   (when (featurep 'cygwin-mount)
  3090   (when (featurep 'cygwin-mount)
  3091     (setq path (my-dos2cygwin-path path)))
  3091     (setq path (my/dos2cygwin-path path)))
  3092   (python-send-string (format "import sys; sys.path.append(\"%s\")" (expand-file-name path))) )
  3092   (python-send-string (format "import sys; sys.path.append(\"%s\")" (expand-file-name path))) )
  3093 
  3093 
  3094 (defun my-python-django-fix (path)
  3094 (defun my/python-django-fix (path)
  3095   "XXX not work on Cygwin + naive Emacs."
  3095   "XXX not work on Cygwin + naive Emacs."
  3096   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
  3096   (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
  3097   (when (featurep 'cygwin-mount)
  3097   (when (featurep 'cygwin-mount)
  3098     (setq path (my-dos2cygwin-path path))
  3098     (setq path (my/dos2cygwin-path path))
  3099     )
  3099     )
  3100   (let ((file (concat path "manage.py")))
  3100   (let ((file (concat path "manage.py")))
  3101     (if (file-exists-p file)
  3101     (if (file-exists-p file)
  3102         (python-send-string (format "import os; os.chdir(\"%s\"); execfile(\"%s\")" path file))
  3102         (python-send-string (format "import os; os.chdir(\"%s\"); execfile(\"%s\")" path file))
  3103       (error (format "file '%s' does not exist" file))
  3103       (error (format "file '%s' does not exist" file))
  3267  htmlize-convert-nonascii-to-entities nil)
  3267  htmlize-convert-nonascii-to-entities nil)
  3268 
  3268 
  3269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3270 (message "html")
  3270 (message "html")
  3271 
  3271 
  3272 (defun my-html-charref-escape-region (start end)
  3272 (defun my/html-charref-escape-region (start end)
  3273   (interactive "r")
  3273   (interactive "r")
  3274   (save-excursion
  3274   (save-excursion
  3275     (save-restriction
  3275     (save-restriction
  3276       (narrow-to-region start end)
  3276       (narrow-to-region start end)
  3277       (goto-char (point-min))
  3277       (goto-char (point-min))
  3280       (while (search-forward "<") (replace-match "&lt;"))
  3280       (while (search-forward "<") (replace-match "&lt;"))
  3281       (goto-char (point-min))
  3281       (goto-char (point-min))
  3282       (while (search-forward ">") (replace-match "&gt;"))
  3282       (while (search-forward ">") (replace-match "&gt;"))
  3283       )))
  3283       )))
  3284 
  3284 
  3285 (defun my-html-charref-from-char (char)
  3285 (defun my/html-charref-from-char (char)
  3286   (format "&#%d;" char)
  3286   (format "&#%d;" char)
  3287   )
  3287   )
  3288 
  3288 
  3289 (defun my-html-charref-from-string (string)
  3289 (defun my/html-charref-from-string (string)
  3290   (let ((res ""))
  3290   (let ((res ""))
  3291     (mapc
  3291     (mapc
  3292      (lambda (char) (setq res (concat res (my-html-charref-from-char char))))
  3292      (lambda (char) (setq res (concat res (my/html-charref-from-char char))))
  3293      string)
  3293      string)
  3294     res
  3294     res
  3295     ) )
  3295     ) )
  3296 
  3296 
  3297 (defun my-html-charref-escape-region2 (begin end &optional prefix)
  3297 (defun my/html-charref-escape-region2 (begin end &optional prefix)
  3298   (interactive "r\nP")
  3298   (interactive "r\nP")
  3299   (if prefix
  3299   (if prefix
  3300       (save-excursion
  3300       (save-excursion
  3301         (goto-char begin)
  3301         (goto-char begin)
  3302         (insert (my-html-charref-from-string (delete-and-extract-region begin end))))
  3302         (insert (my/html-charref-from-string (delete-and-extract-region begin end))))
  3303     (my-html-charref-from-string (buffer-substring begin end))
  3303     (my/html-charref-from-string (buffer-substring begin end))
  3304     ))
  3304     ))
  3305 
  3305 
  3306 (defun my-html-charref-to-string (html)
  3306 (defun my/html-charref-to-string (html)
  3307   "Return string with replaced decimal/hex and string charrefs by
  3307   "Return string with replaced decimal/hex and string charrefs by
  3308 correcponding UTF-8 symbol."
  3308 correcponding UTF-8 symbol."
  3309   (let (str)
  3309   (let (str)
  3310     (with-temp-buffer
  3310     (with-temp-buffer
  3311       (insert html)
  3311       (insert html)
  3329             (replace-match "\"" t t))
  3329             (replace-match "\"" t t))
  3330            ((equal str "amp")
  3330            ((equal str "amp")
  3331             (replace-match "&" t t)))) ))
  3331             (replace-match "&" t t)))) ))
  3332       (buffer-string))))
  3332       (buffer-string))))
  3333 
  3333 
  3334 (defun my-html-charref-unescape-region (begin end &optional prefix)
  3334 (defun my/html-charref-unescape-region (begin end &optional prefix)
  3335   (interactive "r\nP")
  3335   (interactive "r\nP")
  3336   (if prefix
  3336   (if prefix
  3337       (save-excursion
  3337       (save-excursion
  3338         (goto-char begin)
  3338         (goto-char begin)
  3339         (insert (my-html-charref-to-string (delete-and-extract-region begin end))))
  3339         (insert (my/html-charref-to-string (delete-and-extract-region begin end))))
  3340     (my-html-charref-to-string (buffer-substring begin end))
  3340     (my/html-charref-to-string (buffer-substring begin end))
  3341     ))
  3341     ))
  3342 
  3342 
  3343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3344 (message "nxml")
  3344 (message "nxml")
  3345 
  3345 
  3428 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3428 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3429 (message "psgml")
  3429 (message "psgml")
  3430 
  3430 
  3431 (eval-when 'compile (require 'psgml nil t))
  3431 (eval-when 'compile (require 'psgml nil t))
  3432 
  3432 
  3433 (defvar my-html-template
  3433 (defvar my/html-template
  3434       '("html"
  3434       '("html"
  3435         (nil
  3435         (nil
  3436          "\n<head>" \n
  3436          "\n<head>" \n
  3437          "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" (read-string "Charset: ") "\">" \n
  3437          "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" (read-string "Charset: ") "\">" \n
  3438          "<title>" (setq str (read-string "Title: ")) "</title>\n"
  3438          "<title>" (setq str (read-string "Title: ")) "</title>\n"
  3446 
  3446 
  3447 (my--eval-after-load sgml-mode
  3447 (my--eval-after-load sgml-mode
  3448   (unless (featurep 'psgml)
  3448   (unless (featurep 'psgml)
  3449     (setq html-tag-alist
  3449     (setq html-tag-alist
  3450           (cons
  3450           (cons
  3451            my-html-template
  3451            my/html-template
  3452            (my-filter
  3452            (my/filter
  3453             (lambda (item) (not (equal (car item) "html")))
  3453             (lambda (item) (not (equal (car item) "html")))
  3454             html-tag-alist)))
  3454             html-tag-alist)))
  3455     (add-to-list 'html-tag-alist '("script" (\n) ("type" "text/javascript") ))
  3455     (add-to-list 'html-tag-alist '("script" (\n) ("type" "text/javascript") ))
  3456     (add-to-list 'html-tag-alist '("style" (\n) ("type" "text/css") )) ))
  3456     (add-to-list 'html-tag-alist '("style" (\n) ("type" "text/css") )) ))
  3457 
  3457 
  3546 ;; This enable "define" and "&var" syntax.
  3546 ;; This enable "define" and "&var" syntax.
  3547 (setq sql-oracle-scan-on nil)
  3547 (setq sql-oracle-scan-on nil)
  3548 
  3548 
  3549 (add-hook 'sql-interactive-mode-hook (lambda () (toggle-truncate-lines 1)))
  3549 (add-hook 'sql-interactive-mode-hook (lambda () (toggle-truncate-lines 1)))
  3550 
  3550 
  3551 (defun my-sql-explain-paragraph ()
  3551 (defun my/sql-explain-paragraph ()
  3552   "Send the current paragraph to the SQL process with \"explain \" keyword.
  3552   "Send the current paragraph to the SQL process with \"explain \" keyword.
  3553 Works at least for MySql/MariaDB."
  3553 Works at least for MySql/MariaDB."
  3554   (interactive)
  3554   (interactive)
  3555   (let ((start (save-excursion
  3555   (let ((start (save-excursion
  3556                  (backward-paragraph)
  3556                  (backward-paragraph)
  3559                (forward-paragraph)
  3559                (forward-paragraph)
  3560                (point))))
  3560                (point))))
  3561     (sql-send-string (concat "explain " (buffer-substring-no-properties start end)))))
  3561     (sql-send-string (concat "explain " (buffer-substring-no-properties start end)))))
  3562 
  3562 
  3563 (my--eval-after-load sql
  3563 (my--eval-after-load sql
  3564   (define-key sql-mode-map (kbd "C-c C-e") 'my-sql-explain-paragraph))
  3564   (define-key sql-mode-map (kbd "C-c C-e") 'my/sql-explain-paragraph))
  3565 
  3565 
  3566 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3566 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3567 (message "backuping")
  3567 (message "backuping")
  3568 
  3568 
  3569 (setq
  3569 (setq