.emacs-obsolete
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 25 Dec 2023 20:15:49 +0200
changeset 1772 d97be992a1f9
parent 1680 77bbb8dc0e0c
permissions -rw-r--r--
Introduced Org state FAILED.

;; -*- mode: emacs-lisp; coding: utf-8; fill-column: 78 -*-

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(iswitchb-mode 1)

(setq iswitchb-regexp t)
(setq iswitchb-use-virtual-buffers t)
(setq iswitchb-buffer-ignore
      '("^ "
        "^\\*Buffer"
        "^\\*Completions\\*"
        "^\\*tramp"
        "^\\*Dired log\\*"
        "^\\*Quail Completions\\*"
        "^\\*Disabled Command\\*"
        "^TAGS"
        ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'ffap)
(ffap-bindings)

;; I usually mistype "C-x C-f" to "C-x d" or "C-x C-d", so always use find-file,
;; because when file if directory find-file load dired, if regular file open it.
(global-set-key (kbd "C-x C-f") 'find-file-at-point)
(global-set-key (kbd "C-x C-d") 'find-file-at-point)
(global-set-key (kbd "C-x d") 'find-file-at-point)

;; Stop 'ffap' in Dired as its suggestion is inconvenient.
(define-key dired-mode-map (kbd "C-x C-f") 'find-file)
(define-key dired-mode-map (kbd "C-x C-d") 'find-file)
(define-key dired-mode-map (kbd "C-x d") 'find-file)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(mapc (lambda (ext) (add-to-list 'completion-ignored-extensions ext))
      '(
        ".class" "~" ".aux"
        ".o" ".obj" ".map" ".lib" ".lo" ".la" ".a" ".bin" ".exe"
        ;; Place dir at end to appear at the start of completion-ignored-extensions.
        "CVS/" ".hg/" ".svn/" ".git/" ".bzr/"
        ) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun my-find-subdirs (dir)
  (if (file-directory-p dir)
      (cons dir (apply 'append (mapcar 'my-find-subdirs (directory-files dir t "^[^.]")) ) )
    ))
(defun my-add-subdirs-to-load-path (dir)
  (mapc
   (lambda (d)
     (add-to-list 'load-path d t)
     (message "Load-path updated with: %s" d)
     )
   (my-find-subdirs dir)) )

(my-add-subdirs-to-load-path my-lisp-usr-home-dir)
(my-add-subdirs-to-load-path my-lisp-dir)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)
(add-hook 'comint-mode-hook 'ansi-color-for-comint-mode-on)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; For Cygwin.

(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "TODO, XXX, FIXME highlight")

(defface my-contrasty-face
  '((t :background "pink" :foreground "red" :weight bold))
  "Font for showing conflicts."
  :group 'basic-faces)

(dolist (mode (append my-devel-mode-list my-text-mode-list))
  (font-lock-add-keywords
   mode
   `(
     ;; 64 times, for highlight C-u C-u C-u <key>
     ("\\([^[:space:]]\\)\\1\\{63\\}" 0 'my-contrasty-face t) )) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make mouse clicks work in xterm (and iTerm).

(when (not (window-system))
  (xterm-mouse-mode +1))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "org-mode, GTD, PIM, organize, todo")

(when (>= emacs-major-version 22)
  (require 'org))

(when (or (featurep 'org) (featurep 'org-install))
  (message "Many lines here..."))

(cond
 ((featurep 'org-capture)
  (setq org-default-notes-file my-org-agenda-todo-file)
  (setq org-capture-templates
        '(("t" "Todo" entry (file my-org-agenda-todo-file) "* %?\n  SCHEDULED: %T")))
  (define-key global-map "\C-vr"
    (lambda () (interactive) (org-capture nil "t")))
  )
 ((or (featurep 'remember) (fboundp 'remember))
  (setq remember-annotation-functions '(org-remember-annotation))
  (setq remember-handler-functions '(org-remember-handler))
  (add-hook 'remember-mode-hook 'org-remember-apply-template)
  (define-key global-map "\C-vr" 'org-remember)
  (setq org-remember-templates
        ;; With one item org-mode do not prompt choose template.
        `(
          ("todo" ?t "* TODO %?" ,my-org-agenda-todo-file)
          ;; ("note" ?n "* %?\n" ,my-org-agenda-note-file)
          ))
  (setq org-remember-store-without-prompt t)
  (org-remember-insinuate)
  ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "highlight selected text")

(cond
 ((= emacs-major-version 21) (pc-selection-mode))
 ((>= emacs-major-version 22) (pc-selection-mode 1)) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "keyboard, mouse")

(setq my-russian-input-method 'russian-computer)
(setq my-ukranian-input-method 'ukrainian-computer)
(setq my-ipa-input-method 'ipa-x-sampa)
(when (<= emacs-major-version 21)
  (setq my-russian-input-method 'cyrillic-jcuken)
  (setq my-ukranian-input-method 'cyrillic-jcuken))
(setq default-input-method my-russian-input-method)

(defun my-toggle-input-method (&optional arg)
  (interactive "P")
  (if (numberp arg)
      (cond
       ((eq arg 1)
        (activate-input-method nil))
       ((eq arg 2)
        (activate-input-method 'my-russian-input-method))
       ((eq arg 3)
        (activate-input-method 'my-ukranian-input-method))
       ((eq arg 4)
        (activate-input-method 'greek))
       ((eq arg 5)
        (activate-input-method 'my-ipa-input-method))
       ((eq arg 6)
        (activate-input-method 'TeX)) )
    (toggle-input-method arg)) )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "dired")

(when (>= emacs-major-version 22)
  ;; Enable 'a' command.
  (put 'dired-find-alternate-file 'disabled nil)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "devel, programming")

(when (>= emacs-major-version 22)
  (add-to-list 'magic-mode-alist '(my--c++-header-file-p . c++-mode))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "desktop")

(when (>= emacs-major-version 22)
  (require 'desktop)
  (add-to-list 'desktop-path desktop-dirname)
  (setq desktop-restore-frames nil)
  (desktop-save-mode 1)
  (setq
   desktop-globals-to-save
   (append
    '((file-name-history . 100)
      (compile-history . 100)
      (command-history . 100)
      (extended-command-history . 100)
      (shell-command-history . 100)
      (search-ring . 20)
      (query-replace-history . 100)
      (regexp-history . 100)
      (grep-history . 100)
      (minibuffer-history . 100)
      tags-file-name
      register-alist)
    desktop-globals-to-save))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "coding system, charset, locale, lang")

;; Emacs 23.1 no longer need codepage-setup.
(when (<= emacs-major-version 22)
  (codepage-setup 866)
  (codepage-setup 1251)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "jdone")

(ignore-errors
  (require 'jdone)
  (jdone-setup-key-binding)
  (jdone-integrate-hook)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "yasnippet")

(setq my-yas-root-directory "~/.emacs.d/my-yas")
(setq yas/ignore-filenames-as-triggers t)

;; (my--eval-after-load yasnippet
;;   (cond
;;    ((listp yas/root-directory) (add-to-list 'yas/root-directory my-yas-root-directory))
;;    ((stringp yas/root-directory) (setq yas/root-directory (list my-yas-root-directory yas/root-directory)))
;;    (t (error "I expect that yas/root-directory is a list of string")) )
;;   (mapc 'yas/load-directory yas/root-directory))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "ECB")

(setq ecb-tip-of-the-day nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "vc-mode, VCS, version control, cvs, svn, mercurial, hg, bazaar, bzr, git, fossil")

(when (equal window-system 'w32)
  (modify-coding-system-alist 'process "cvs" '(cp1251-dos . cp1251-dos))
  (modify-coding-system-alist 'process "svn" '(cp1251 . cp1251))
  (setq vc-svn-checkin-switches '("--encoding" "UTF-8"))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "fortune")
(setq fortune-file "~/XXX")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "bbdb")

(eval-when 'compile (require 'bbdb nil t))

(setq
 bbdb-offer-save 1
 bbdb-use-pop-up t
 bbdb-electric-p t
 bbdb-popup-target-lines  1
 )

(setq bbdb-complete-name-full-completion t)
(setq bbdb-completion-type 'primary-or-name)
(setq bbdb-complete-name-allow-cycling t)

(setq bbdb-file "~/.gnus/bbdb")

;; (bbdb-initialize 'gnus 'message)
;; (bbdb-insinuate-message)
;; (add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "rcirc")

(eval-when 'compile (require 'rcirc))

;; Turn on logging everything to a special buffer, for debugging.
;; (setq rcirc-debug-flag t)

(add-hook 'rcirc-mode-hook (lambda () (rcirc-track-minor-mode 1)))
(setq rcirc-time-format "%H:%M ")
(defun rcirc-handler-301 (process cmd sender args)
  "/away message handler.")

(setq rcirc-default-server "irc.freenode.net")
(setq rcirc-default-port 6667)
(setq rcirc-default-nick user-nick)
(setq rcirc-default-user-full-name user-full-name)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "psvn")

(setq svn-status-verbose t)
(setq svn-status-hide-unmodified t)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "DVC")

(when (featurep 'dvc-emacs)
  (setq dvc-tips-enabled nil)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setq smtpmail-smtp-server "192.168.0.xxx")
(setq smtpmail-smtp-service "25")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "font selection")

(defvar my-preferred-font
  (cond
   ((eq window-system 'x)
    "-misc-fixed-medium-r-normal--14-*-*-*-c-*-iso10646-1")
   ((eq window-system 'w32)
    "Courier New-10:antialias=none")
   (t nil)))
(when my-preferred-font
  (set-frame-font my-preferred-font)
  (set-fontset-font "fontset-default" 'latin my-preferred-font)
  (set-fontset-font "fontset-default" 'phonetic my-preferred-font)
  (set-fontset-font "fontset-default" 'cyrillic my-preferred-font)
  (set-fontset-font "fontset-default" 'greek my-preferred-font))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "font selection")

(cond
 ((eq window-system 'x)
  (set-frame-font "-*-terminus-*-*-*--14-*-*-*-c-*-*-*")
  (setq-default line-spacing nil)
  (set-fontset-font nil 'cyrillic "-*-terminus-*-*-*--14-*-*-*-c-*-*-*")
  (set-fontset-font nil 'greek "-*-terminus-*-*-*--14-*-*-*-c-*-*-*")
  (set-fontset-font nil nil "-misc-fixed-*-*-*--13-*-*-*-*-*-*-*")
  (set-fontset-font nil 'phonetic "-misc-fixed-*-*-*--13-*-*-*-*-*-*-*")
  (set-fontset-font nil 'symbol "-misc-fixed-*-*-*--13-*-*-*-*-*-*-*")
  ;; MODIFIER LETTER is not present in terminus, this includes ˌːˈ characters.
  (set-fontset-font nil '(#x02C0 . #x02FF) "-misc-fixed-*-*-*--13-*-*-*-*-*-*-*") )
 ((eq window-system 'w32)
  (set-frame-font "Courier New-10:antialias=none") ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "smex")

;; icomplete also allow flex matching with '*', try 'M-x *copy*as TAB'

;; `smex' is  alternative for `icomplete'.
;; https://github.com/nonsequitur/smex/
;; It is based on `ido'.
(ignore-errors
  (require 'smex)
  (smex-initialize)
  (global-set-key (kbd "M-X") 'smex))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "ag")

(ignore-errors (require 'ag))

(defun my/ag (regex)
  "Search with ag from project roor without prefix and from
`default-directory' with prefix."
  (interactive (list (ag/read-from-minibuffer "Search regex")))
  (if current-prefix-arg
      (let ((current-prefix-arg nil)) (ag-regexp regex default-directory))
    (ag-project-regexp regex)))

(setq ag-group-matches t)
(setq ag-highlight-search t)
(when (featurep 'ag)
  (global-set-key [f7] 'my/ag))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "rgrep")

(global-set-key [f7] 'rgrep)

(defun lzgrep ()
  (interactive)
  (let ( (grep-template "zgrep <C> -nH -e <R> <F>") (grep-find-ignored-files nil) )
    (cl-flet ( (grep-compute-defaults () nil) )
      (call-interactively #'lgrep))))

(defun rzgrep ()
  (interactive)
  (let ( (grep-find-template "find . -type f <F> -exec zgrep <C> -nH -e <R> {} +") (grep-find-ignored-files nil) )
    (cl-flet ( (grep-compute-defaults () nil) )
      (call-interactively #'rgrep))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "CEDET, semantic, SRecord")

;; For debug use 'semantic-debug-idle-function' and 'semantic-debug-idle-work-function'.

(eval-when 'compile
  (require 'cedet nil t)
  (require 'srecode nil t)
  (require 'srecode/table nil t)
  (require 'semantic nil t)
  (require 'semantic/idle nil t)
  (require 'ede/linux nil t))

(eval-and-compile
  (when (or
         (and (= emacs-major-version 23) (>= emacs-minor-version 2))
         (>= emacs-major-version 24) )
    (require 'cedet)
    (require 'mode-local)))

(defun my-srecode-reload-templates ()
  "Reload all templates under `srecode-map-load-path'. Useful
during template developing."
  (interactive)
  (setq srecode-mode-table-list nil
        srecode-current-map nil)
  (srecode-map-update-map) )

(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)

(when (featurep 'cedet)
  (require 'semantic)
  (global-semantic-idle-scheduler-mode 1)
  (global-semantic-idle-summary-mode 1)
  (global-semantic-idle-completions-mode -1)
  (global-semantic-mru-bookmark-mode 1)
  ;; (setq semantic-stickyfunc-sticky-classes '(function type variable include package))
  (global-semantic-stickyfunc-mode -1)
  (global-semantic-highlight-func-mode -1)
  (global-semantic-decoration-mode 1)
  (when (fboundp 'global-semantic-idle-local-symbol-highlight-mode)
    (global-semantic-idle-local-symbol-highlight-mode 1))
  (setq semantic-idle-scheduler-idle-time 10)
  (setq semantic-idle-scheduler-work-idle-time 60)
  (setq semantic-idle-scheduler-max-buffer-size 100000)
  ;; (setq semantic-idle-work-parse-neighboring-files-flag nil)
  ;; semantic-dependency-system-include-path, semantic-customize-system-include-path
  ;; file local project unloaded system recursive
  (setq-mode-local c-mode semanticdb-find-default-throttle '(file local))
  (add-hook 'c-mode-hook (lambda nil (semantic-add-system-include "~/.emacs.d/include" 'c-mode)))
  (add-hook 'c-mode-hook (lambda nil (semantic-add-system-include "~/.emacs.d/include" 'c++-mode)))
  (global-semanticdb-minor-mode 1)
  (ignore-errors
    (global-cedet-m3-minor-mode 1))
  (semantic-mode 1)
  (global-ede-mode 1)
  (require 'srecode)
  (defvar srecode-map-load-path nil)
  (add-to-list 'srecode-map-load-path (locate-user-emacs-file "srecode/"))
  (global-srecode-minor-mode 1)
  (add-hook 'prog-mode-hook 'srecode-minor-mode)
  (ignore-errors
    (cedet-ectag-version-check)
    (semantic-load-enable-primary-ectags-support))
  (ignore-errors
    (cedet-gnu-global-version-check)
    (require 'cedet-global)
    (semanticdb-enable-gnu-global-databases 'c-mode)
    (semanticdb-enable-gnu-global-databases 'c++-mode))
  (ignore-errors
    (require 'cedet-java))
  (setq project-linux-build-directory-default 'same
        project-linux-architecture-default "x86")
  ;; (require 'semantic/db-javap)
  ;; (add-to-list 'ede-locate-setup-options 'ede-locate-idutils)
  ;; (add-to-list 'ede-locate-setup-options 'ede-locate-global)
  ;; (ignore-errors (require 'cedet-idutils))
  (ignore-errors
    (require 'semantic/ia)
    (define-key semantic-mode-map (kbd "C-c , .") 'semantic-ia-fast-jump)
    (define-key semantic-mode-map (kbd "C-c , d") 'semantic-ia-show-doc)
    (define-key semantic-mode-map (kbd "C-c , D") 'semantic-ia-show-summary)
    (define-key semantic-mode-map (kbd "C-c , ?") 'semantic-ia-complete-symbol-menu)
    ;; (define-key semantic-mode-map [(control return)] 'semantic-ia-complete-symbol)
    ;; (define-key semantic-mode-map (kbd "C-c , C") 'semantic-ia-describe-class)
    ;; semantic-decoration-include-visit
    ;; semantic-analyze-proto-impl-toggle
    )
  ;; END OF: (when (featurep 'cedet) ...)
  )