[all] Remove fish and emacs (dedicated repositories).

This commit is contained in:
Mikaël Capelle 2020-09-13 10:20:06 +00:00
parent 67141d8dc5
commit 284c216bd8
88 changed files with 0 additions and 16392 deletions

View File

@ -1,455 +0,0 @@
;;; init.el --- -*- lexical-binding: t -*-
;;; Init file for emacs
;;; Commentary:
;; Init file, load everything necessary to have a full functional Emacs, this should
;; not be used with Emacs < 24.
;;; Code:
(add-to-list 'load-path "~/.emacs.d/one-file-mode/")
;; Themes
(setq custom-theme-directory "~/.emacs.d/themes/")
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;; Packages
(require 'package) ;; You might already have this line
(setq package-user-dir (expand-file-name "elpa" user-emacs-directory)
package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("cselpa" . "http://elpa.thecybershadow.net/packages/")))
(unless (bound-and-true-p package--initialized)
(setq package-enable-at-startup nil) ; To prevent initializing twice
(package-initialize))
;; set use-package-verbose to t for interpreted .emacs,
;; and to nil for byte-compiled .emacs.elc.
(eval-and-compile
(setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
;; Install use-package if not installed
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-and-compile
(setq use-package-always-ensure t)
(setq use-package-expand-minimally t)
(setq use-package-compute-statistics t)
(setq use-package-enable-imenu-support t))
(eval-when-compile
(require 'use-package)
(require 'bind-key))
(use-package auto-package-update
:if (not (daemonp))
:custom
(auto-package-update-interval 7) ;; in days
(auto-package-update-prompt-before-update t)
(auto-package-update-delete-old-versions t)
(auto-package-update-hide-results t)
:config
(auto-package-update-maybe))
(use-package diminish)
(require 'iso-transl)
(global-display-line-numbers-mode)
;; No menu, scrollbar, displayline and column
(menu-bar-mode -1)
(tool-bar-mode -1)
(when (display-graphic-p)
(scroll-bar-mode -1))
(column-number-mode t)
(line-number-mode t)
(desktop-save-mode t)
;; Command rebinding
;; M-f (forward-word) : Déplacement d'un mot vers la droite du curseur.
;; M-b (backward-word) : Déplacement d'un mot vers la gauche du curseur.
;; C-a (beginning-of-line) : Déplacement au début de la ligne courante.
;; C-e (end-of-line) : Déplacement à la fin de la ligne courante.
;; M-{ (backward-paragraph) : Déplacement vers le paragraphe précédent.
(global-set-key (kbd "M-p") 'backward-paragraph)
;; M-} (forward-paragraph) : Déplacement vers le paragraphe suivant.
(global-set-key (kbd "M-n") 'forward-paragraph)
;; C-v (scroll-up) : Déplacement d'un écran vers le bas.
;; M-v (scroll-down) : Déplacement d'un écran vers le haut.
;; M-> (end-of-buffer) : Déplacement à la fin du buffer.
;; M-< (beginning-of-buffer) : Déplacement au début du buffer.
(use-package material-theme
:config
(load-theme 'material t))
;; No split screen at startup
(setq inhibit-startup-screen t)
;; Or if you use use-package
(setq dashboard-items '((recents . 5)
;; (bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-set-navigator t)
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(add-hook 'dashboard-mode-hook (lambda () (display-line-numbers-mode -1)))
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
(use-package ace-window
:bind ("C-x C-o" . ace-window))
;; Encoding
(set-language-environment "UTF-8")
;; Selection mode
(delete-selection-mode 1)
;; Indentation mode
(setq-default indent-tabs-mode nil)
(setq tab-width 4)
;; Compilation coloration
(ignore-errors
(require 'ansi-color)
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))
;; Retrieve PATH from fish shell
(when (memq window-system '(mac ns x))
(setq exec-path-from-shell-shell-name "/usr/local/bin/fish")
(exec-path-from-shell-initialize))
;; Auto complete + Yasnippet
(use-package projectile
:config
(projectile-mode 1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(setq projectile-enable-caching t))
(use-package helm
:config
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x r b") 'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x C-b") 'helm-buffers-list)
(helm-mode 1)
(add-to-list 'helm-boring-buffer-regexp-list "\\*.*"))
(use-package helm-projectile
:after (helm projectile)
:config
(setq projectile-completion-system 'helm)
(helm-projectile-on))
(use-package yasnippet
:config
(yas-global-mode 1))
(use-package flycheck
:config
(add-hook 'flycheck-after-syntax-check-hook 'flycheck-autolist-hook)
(global-flycheck-mode)
(setq flycheck-emacs-lisp-load-path "inherict")
(setq flycheck-clang-args '("-stdlib=libc++" "-W" "-Wall"))
(add-hook 'c++-mode-hook
(lambda ()
(setq-local flycheck-clang-language-standard "c++14"))))
(use-package flycheck-pos-tip
:after (flycheck)
:config
(add-hook 'flycheck-mode-hook 'flycheck-pos-tip-mode))
(use-package flycheck-color-mode-line
:after (flycheck)
:config
(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
(use-package company
:config
(add-hook 'after-init-hook 'global-company-mode)
(global-set-key (kbd "M-/") 'company-complete))
(use-package company-c-headers
:config
(add-to-list 'company-backends 'company-c-headers))
(use-package company-jedi
:config
(add-to-list 'company-backends 'company-jedi))
(use-package company-web
:config
(add-to-list 'company-backends 'company-web-html))
; C++
(use-package modern-cpp-font-lock
:ensure t)
(add-hook 'c++-mode-hook #'modern-c++-font-lock-mode)
;; Doc mode
(require 'doc-mode)
(add-hook 'c-mode-common-hook 'doc-mode)
(add-hook 'c++-mode-common-hook 'doc-mode)
;; Latex
(use-package auctex
:defer t
:config
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(defun my-latex-mode-setup ()
"Redefines and updates variables for various customizations."
(setq LaTeX-paragraph-commands
'("If" "State" "Loop" "For" "ForAll"))
(setq LaTeX-begin-regexp
(concat LaTeX-begin-regexp "\\|If\\b" "\\|Loop\\b" "\\|For\\b" "\\|ForAll\\b"))
(setq LaTeX-end-regexp
(concat LaTeX-end-regexp "\\|EndIf\\b" "\\|EndLoop\\b"
"\\|EndFor\\b" "\\|Else\\b" "\\|ElsIf\\b"))
(setq LaTeX-paragraph-commands-regexp (LaTeX-paragraph-commands-regexp-make))
(defun LaTeX-indent-level-count ()
"Count indentation change caused by all \\left, \\right, \\begin, and
\\end commands in the current line."
(save-excursion
(save-restriction
(let ((count 0))
(narrow-to-region (point)
(save-excursion
(re-search-forward
(concat "[^" TeX-esc "]"
"\\(" LaTeX-indent-comment-start-regexp
"\\)\\|\n\\|\\'"))
(backward-char)
(point)))
(while (search-forward TeX-esc nil t)
(cond
((looking-at "left\\b")
(setq count (+ count LaTeX-left-right-indent-level)))
((looking-at "right\\b")
(setq count (- count LaTeX-left-right-indent-level)))
((looking-at LaTeX-begin-regexp)
(setq count (+ count LaTeX-indent-level)))
((looking-at "Else\\b"))
((looking-at "ElsIf\\b"))
((looking-at LaTeX-end-regexp)
(setq count (- count LaTeX-indent-level)))
((looking-at (regexp-quote TeX-esc))
(forward-char 1))))
count)))))
(add-to-list 'LaTeX-verbatim-environments "code")
(add-to-list 'LaTeX-indent-environment-list
'("code" current-indentation))
(add-hook 'LaTeX-mode-hook 'my-latex-mode-setup)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(require 'tex)
(TeX-global-PDF-mode t)
)
(use-package company-auctex
:after (auctex company)
:config (company-auctex-init))
;; (add-to-list 'ispell-local-dictionary-alist '("francais-hunspell"
;; "[[:alpha:]]"
;; "[^[:alpha]]"
;; "[']"
;; t
;; ("-d" "fr_FR")
;; nil
;; iso-8859-1))
;; magit
(use-package magit
:config
(add-hook 'after-save-hook 'magit-after-save-refresh-status))
;; CSS style
(setq css-indent-offset 2)
;; Markdown mode
(use-package markdown-mode
:mode "\\.text\\'" "\\.markdown\\'" "\\.md\\'")
;; White space mode & Fill mode column
(defun my-visual-hook ()
(visual-line-mode t)
;; (visual-fill-column-mode t)
(define-key visual-line-mode-map [remap kill-line] nil)
(whitespace-mode t))
(setq-default fill-column 95)
(setq-default whitespace-line-column 95)
(add-hook 'python-mode-hook (lambda () (setq-local whitespace-line-column 100)))
(add-hook 'LaTeX-mode-hook (lambda () (setq-local whitespace-line-column -1)))
(add-hook 'markdown-mode-hook (lambda () (setq-local whitespace-line-column -1)))
(add-hook 'web-mode-hook (lambda () (setq-local whitespace-line-column -1)))
(add-hook 'text-mode-hook 'my-visual-hook)
(add-hook 'prog-mode-hook 'my-visual-hook)
(add-hook 'before-save-hook 'whitespace-cleanup)
;; Electric pair mode
(electric-pair-mode 1)
(show-paren-mode 1)
(setq show-paren-delay 0)
;; C mode
(setq c-default-style "k&r")
(setq c-basic-offset 4)
(defun ac-cc-mode-setup ()
"Initialization hook for CC-mode runs before any other hooks."
(hide-ifdef-mode)
(hs-minor-mode)
(setq hide-ifdef-shadow t))
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'c++-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(setq c-doc-comment-style
'((java-mode . javadoc)
(pike-mode . autodoc)
(c-mode . javadoc)
(c++-mode . javadoc)))
(add-to-list 'auto-mode-alist '("\\.hpp\\'" . c++-mode))
;; Run C programs directly from within emacs
(setq execute-command nil)
(setq execute-buffer-name "*output*")
(setq execute-process-name "execute")
(defun set-execute-command ()
(interactive)
(setq sp (split-string (read-from-minibuffer "Execute command: ")))
(setq execute-command (combine-and-quote-strings (cons (file-truename (car sp)) (cdr sp)))))
(defun kill-execute-c-program ()
(interactive)
(if (get-process execute-process-name)
(delete-process (get-process execute-process-name))))
(defun execute-c-program ()
(interactive)
(if (not execute-command) (set-execute-command))
(kill-execute-c-program)
(setq old-buffer (current-buffer))
(setq output-buffer (get-buffer-create execute-buffer-name))
(switch-to-buffer-other-window output-buffer)
(end-of-buffer)
(insert (concat (propertize execute-command 'face 'bold) "\n"))
(switch-to-buffer-other-window old-buffer)
(start-process-shell-command execute-process-name execute-buffer-name execute-command))
(defun key-c-mode-setup ()
(local-set-key (kbd "C-c C-c") 'smart-compile)
(local-set-key (kbd "C-c C-r") 'execute-c-program)
(local-set-key [f3] 'kill-execute-c-program)
(local-set-key [f4] 'set-execute-command))
(add-hook 'c++-mode-common-hook 'key-c-mode-setup)
(add-hook 'c-mode-common-hook 'key-c-mode-setup)
;; Flyspell dictionarie
(defun fd-switch-dictionary ()
(interactive)
(let* ((dic ispell-current-dictionary)
(change (if (string= dic "francais") "english" "francais")))
(ispell-change-dictionary change)
(message "Dictionary switched from %s to %s" dic change)
))
(defun key-latex-mode-setup ()
(local-set-key [f8] 'fd-switch-dictionary))
(add-hook 'LaTeX-mode-hook 'key-latex-mode-setup)
;; python
(use-package flycheck-mypy)
(use-package elpy
:config
(when (load "flycheck" t t)
(flycheck-add-next-checker 'python-flake8 'python-mypy)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt")
;; (setq python-shell-interpreter "jupyter"
;; python-shell-interpreter-args "console --simple-prompt"
;; python-shell-prompt-detect-failure-warning nil)
(add-to-list 'python-shell-completion-native-disabled-interpreters
"jupyter")
:init
(setq elpy-rpc-backend "jedi")
(setq elpy-rpc-python-command "python3")
(elpy-enable))
(add-hook 'python-mode-hook 'hs-minor-mode)
;; Web mode
(add-to-list 'auto-mode-alist '("\\.ctp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
;;(use-package mmm-mode
;; :config
;; (require 'mmm-auto)
;; (setq mmm-global-mode 'maybe)
;; (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
;; (mmm-add-mode-ext-class nil "\\.ctp\\'" 'html-php)
;; (add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil html-js))
;; (add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil embedded-css))
;; (add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil fancy-html)))
;; Go
(require 'go-template-mode)
;; Dockers
(require 'dockerfile-mode)
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
;; Term
(setq explicit-shell-file-name "/bin/bash")
(defun my-term-hook ()
(visual-fill-column-mode nil)
(visual-line-mode nil))
(add-hook 'term-load-hook 'my-term-hook)
(eval-after-load "term"
'(define-key term-raw-map (kbd "C-c C-y") 'term-paste))
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
(put 'narrow-to-region 'disabled nil)
(provide 'init)
;;; init.el ends here

View File

@ -1,413 +0,0 @@
;;; bind-key.el --- A simple way to manage personal keybindings
;; Copyright (c) 2012-2015 john wiegley
;; Author: John Wiegley <jwiegley@gmail.com>
;; Maintainer: John Wiegley <jwiegley@gmail.com>
;; Created: 16 Jun 2012
;; Version: 1.0
;; Keywords: keys keybinding config dotemacs
;; URL: https://github.com/jwiegley/use-package
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the gnu general public license as
;; published by the free software foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; without any warranty; without even the implied warranty of
;; merchantability or fitness for a particular purpose. see the gnu
;; general public license for more details.
;; You should have received a copy of the gnu general public license
;; along with gnu emacs; see the file copying. if not, write to the
;; free software foundation, inc., 59 temple place - suite 330,
;; boston, ma 02111-1307, usa.
;;; Commentary:
;; If you have lots of keybindings set in your .emacs file, it can be hard to
;; know which ones you haven't set yet, and which may now be overriding some
;; new default in a new emacs version. This module aims to solve that
;; problem.
;;
;; Bind keys as follows in your .emacs:
;;
;; (require 'bind-key)
;;
;; (bind-key "C-c x" 'my-ctrl-c-x-command)
;;
;; If you want the keybinding to override all minor modes that may also bind
;; the same key, use the `bind-key*' form:
;;
;; (bind-key* "<C-return>" 'other-window)
;;
;; If you want to rebind a key only in a particular keymap, use:
;;
;; (bind-key "C-c x" 'my-ctrl-c-x-command some-other-mode-map)
;;
;; To unbind a key within a keymap (for example, to stop your favorite major
;; mode from changing a binding that you don't want to override everywhere),
;; use `unbind-key':
;;
;; (unbind-key "C-c x" some-other-mode-map)
;;
;; To bind multiple keys at once, or set up a prefix map, a `bind-keys' macro
;; is provided. It accepts keyword arguments, please see its documentation
;; for a detailed description.
;;
;; To add keys into a specific map, use :map argument
;;
;; (bind-keys :map dired-mode-map
;; ("o" . dired-omit-mode)
;; ("a" . some-custom-dired-function))
;;
;; To set up a prefix map, use `:prefix-map' and `:prefix' arguments (both are
;; required)
;;
;; (bind-keys :prefix-map my-customize-prefix-map
;; :prefix "C-c c"
;; ("f" . customize-face)
;; ("v" . customize-variable))
;;
;; You can combine all the keywords together. Additionally,
;; `:prefix-docstring' can be specified to set documentation of created
;; `:prefix-map' variable.
;;
;; To bind multiple keys in a `bind-key*' way (to be sure that your bindings
;; will not be overridden by other modes), you may use `bind-keys*' macro:
;;
;; (bind-keys*
;; ("C-o" . other-window)
;; ("C-M-n" . forward-page)
;; ("C-M-p" . backward-page))
;;
;; After Emacs loads, you can see a summary of all your personal keybindings
;; currently in effect with this command:
;;
;; M-x describe-personal-keybindings
;;
;; This display will tell you if you've overriden a default keybinding, and
;; what the default was. Also, it will tell you if the key was rebound after
;; your binding it with `bind-key', and what it was rebound it to.
(require 'cl-lib)
(require 'easy-mmode)
(defgroup bind-key nil
"A simple way to manage personal keybindings"
:group 'emacs)
(defcustom bind-key-column-widths '(18 . 40)
"Width of columns in `describe-personal-keybindings'."
:type '(cons integer integer)
:group 'bind-key)
(defcustom bind-key-segregation-regexp
"\\`\\(\\(C-[chx] \\|M-[gso] \\)\\([CM]-\\)?\\|.+-\\)"
"Regular expression used to divide key sets in the output from
\\[describe-personal-keybindings]."
:type 'regexp
:group 'bind-key)
(defcustom bind-key-describe-special-forms nil
"If non-nil, extract docstrings from lambdas, closures and keymaps if possible."
:type 'boolean
:group 'bind-key)
;; Create override-global-mode to force key remappings
(defvar override-global-map (make-keymap)
"override-global-mode keymap")
(define-minor-mode override-global-mode
"A minor mode so that keymap settings override other modes."
t "")
;; the keymaps in `emulation-mode-map-alists' take precedence over
;; `minor-mode-map-alist'
(add-to-list 'emulation-mode-map-alists
`((override-global-mode . ,override-global-map)))
(defvar personal-keybindings nil
"List of bindings performed by `bind-key'.
Elements have the form ((KEY . [MAP]) CMD ORIGINAL-CMD)")
;;;###autoload
(defmacro bind-key (key-name command &optional keymap predicate)
"Bind KEY-NAME to COMMAND in KEYMAP (`global-map' if not passed).
KEY-NAME may be a vector, in which case it is passed straight to
`define-key'. Or it may be a string to be interpreted as
spelled-out keystrokes, e.g., \"C-c C-z\". See documentation of
`edmacro-mode' for details.
If PREDICATE is non-nil, it is a form evaluated to determine when
a key should be bound. It must return non-nil in such cases.
Emacs can evaluate this form at any time that it does redisplay
or operates on menu data structures, so you should write it so it
can safely be called at any time."
(let ((namevar (make-symbol "name"))
(keyvar (make-symbol "key"))
(kdescvar (make-symbol "kdesc"))
(bindingvar (make-symbol "binding")))
`(let* ((,namevar ,key-name)
(,keyvar (if (vectorp ,namevar) ,namevar
(read-kbd-macro ,namevar)))
(,kdescvar (cons (if (stringp ,namevar) ,namevar
(key-description ,namevar))
(quote ,keymap)))
(,bindingvar (lookup-key (or ,keymap global-map) ,keyvar)))
(add-to-list 'personal-keybindings
(list ,kdescvar ,command
(unless (numberp ,bindingvar) ,bindingvar)))
,(if predicate
`(define-key (or ,keymap global-map) ,keyvar
'(menu-item "" nil :filter (lambda (&optional _)
(when ,predicate
,command))))
`(define-key (or ,keymap global-map) ,keyvar ,command)))))
;;;###autoload
(defmacro unbind-key (key-name &optional keymap)
"Unbind the given KEY-NAME, within the KEYMAP (if specified).
See `bind-key' for more details."
`(progn
(bind-key ,key-name nil ,keymap)
(setq personal-keybindings
(cl-delete-if #'(lambda (k)
,(if keymap
`(and (consp (car k))
(string= (caar k) ,key-name)
(eq (cdar k) ',keymap))
`(and (stringp (car k))
(string= (car k) ,key-name))))
personal-keybindings))))
;;;###autoload
(defmacro bind-key* (key-name command &optional predicate)
"Similar to `bind-key', but overrides any mode-specific bindings."
`(bind-key ,key-name ,command override-global-map ,predicate))
(defun bind-keys-form (args)
"Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
;; jww (2016-02-26): This is a hack; this whole function needs to be
;; rewritten to normalize arguments the way that use-package.el does.
(if (and (eq (car args) :package)
(not (eq (car (cdr (cdr args))) :map)))
(setq args (cons :map (cons 'global-map args))))
(let* ((map (plist-get args :map))
(doc (plist-get args :prefix-docstring))
(prefix-map (plist-get args :prefix-map))
(prefix (plist-get args :prefix))
(filter (plist-get args :filter))
(menu-name (plist-get args :menu-name))
(pkg (plist-get args :package))
(key-bindings (progn
(while (keywordp (car args))
(pop args)
(pop args))
args)))
(when (or (and prefix-map (not prefix))
(and prefix (not prefix-map)))
(error "Both :prefix-map and :prefix must be supplied"))
(when (and menu-name (not prefix))
(error "If :menu-name is supplied, :prefix must be too"))
(let ((args key-bindings)
saw-map first next)
(while args
(if (keywordp (car args))
(progn
(setq next args)
(setq args nil))
(if first
(nconc first (list (car args)))
(setq first (list (car args))))
(setq args (cdr args))))
(cl-flet
((wrap (map bindings)
(if (and map pkg (not (eq map 'global-map)))
(if (boundp map)
bindings
`((eval-after-load
,(if (symbolp pkg) `',pkg pkg)
'(progn ,@bindings))))
bindings)))
(append
(when prefix-map
`((defvar ,prefix-map)
,@(when doc `((put ',prefix-map 'variable-documentation ,doc)))
,@(if menu-name
`((define-prefix-command ',prefix-map nil ,menu-name))
`((define-prefix-command ',prefix-map)))
,@(if (and map (not (eq map 'global-map)))
(wrap map `((bind-key ,prefix ',prefix-map ,map ,filter)))
`((bind-key ,prefix ',prefix-map nil ,filter)))))
(wrap map
(cl-mapcan
(lambda (form)
(if prefix-map
`((bind-key ,(car form) ',(cdr form) ,prefix-map ,filter))
(if (and map (not (eq map 'global-map)))
`((bind-key ,(car form) ',(cdr form) ,map ,filter))
`((bind-key ,(car form) ',(cdr form) nil ,filter)))))
first))
(when next
(bind-keys-form
(if pkg
(cons :package (cons pkg next))
next))))))))
;;;###autoload
(defmacro bind-keys (&rest args)
"Bind multiple keys at once.
Accepts keyword arguments:
:map MAP - a keymap into which the keybindings should be
added
:prefix KEY - prefix key for these bindings
:prefix-map MAP - name of the prefix map that should be created
for these bindings
:prefix-docstring STR - docstring for the prefix-map variable
:menu-name NAME - optional menu string for prefix map
:filter FORM - optional form to determine when bindings apply
The rest of the arguments are conses of keybinding string and a
function symbol (unquoted)."
(macroexp-progn (bind-keys-form args)))
;;;###autoload
(defmacro bind-keys* (&rest args)
(macroexp-progn
(bind-keys-form `(:map override-global-map ,@args))))
(defun get-binding-description (elem)
(cond
((listp elem)
(cond
((eq 'lambda (car elem))
(if (and bind-key-describe-special-forms
(stringp (nth 2 elem)))
(nth 2 elem)
"#<lambda>"))
((eq 'closure (car elem))
(if (and bind-key-describe-special-forms
(stringp (nth 3 elem)))
(nth 3 elem)
"#<closure>"))
((eq 'keymap (car elem))
"#<keymap>")
(t
elem)))
;; must be a symbol, non-symbol keymap case covered above
((and bind-key-describe-special-forms (keymapp elem))
(let ((doc (get elem 'variable-documentation)))
(if (stringp doc) doc elem)))
((symbolp elem)
elem)
(t
"#<byte-compiled lambda>")))
(defun compare-keybindings (l r)
(let* ((regex bind-key-segregation-regexp)
(lgroup (and (string-match regex (caar l))
(match-string 0 (caar l))))
(rgroup (and (string-match regex (caar r))
(match-string 0 (caar r))))
(lkeymap (cdar l))
(rkeymap (cdar r)))
(cond
((and (null lkeymap) rkeymap)
(cons t t))
((and lkeymap (null rkeymap))
(cons nil t))
((and lkeymap rkeymap
(not (string= (symbol-name lkeymap) (symbol-name rkeymap))))
(cons (string< (symbol-name lkeymap) (symbol-name rkeymap)) t))
((and (null lgroup) rgroup)
(cons t t))
((and lgroup (null rgroup))
(cons nil t))
((and lgroup rgroup)
(if (string= lgroup rgroup)
(cons (string< (caar l) (caar r)) nil)
(cons (string< lgroup rgroup) t)))
(t
(cons (string< (caar l) (caar r)) nil)))))
;;;###autoload
(defun describe-personal-keybindings ()
"Display all the personal keybindings defined by `bind-key'."
(interactive)
(with-output-to-temp-buffer "*Personal Keybindings*"
(princ (format (concat "Key name%s Command%s Comments\n%s %s "
"---------------------\n")
(make-string (- (car bind-key-column-widths) 9) ? )
(make-string (- (cdr bind-key-column-widths) 8) ? )
(make-string (1- (car bind-key-column-widths)) ?-)
(make-string (1- (cdr bind-key-column-widths)) ?-)))
(let (last-binding)
(dolist (binding
(setq personal-keybindings
(sort personal-keybindings
(lambda (l r)
(car (compare-keybindings l r))))))
(if (not (eq (cdar last-binding) (cdar binding)))
(princ (format "\n\n%s\n%s\n\n"
(cdar binding)
(make-string (+ 21 (car bind-key-column-widths)
(cdr bind-key-column-widths)) ?-)))
(if (and last-binding
(cdr (compare-keybindings last-binding binding)))
(princ "\n")))
(let* ((key-name (caar binding))
(at-present (lookup-key (or (symbol-value (cdar binding))
(current-global-map))
(read-kbd-macro key-name)))
(command (nth 1 binding))
(was-command (nth 2 binding))
(command-desc (get-binding-description command))
(was-command-desc (and was-command
(get-binding-description was-command)))
(at-present-desc (get-binding-description at-present))
)
(let ((line
(format
(format "%%-%ds%%-%ds%%s\n" (car bind-key-column-widths)
(cdr bind-key-column-widths))
key-name (format "`%s\'" command-desc)
(if (string= command-desc at-present-desc)
(if (or (null was-command)
(string= command-desc was-command-desc))
""
(format "was `%s\'" was-command-desc))
(format "[now: `%s\']" at-present)))))
(princ (if (string-match "[ \t]+\n" line)
(replace-match "\n" t t line)
line))))
(setq last-binding binding)))))
(provide 'bind-key)
;; Local Variables:
;; indent-tabs-mode: nil
;; End:
;;; bind-key.el ends here

View File

@ -1,56 +0,0 @@
(require 'font-lock)
;;###autoload
(define-minor-mode c++1x-minor-mode
"Extra highlighting for c++-mode that includes c++11 and c++14 keywords and features"
:lighter "c++1x"
(defun --copy-face (new-face face)
"Define NEW-FACE from existing FACE."
(copy-face face new-face)
(eval `(defvar ,new-face nil))
(set new-face new-face))
(--copy-face 'font-lock-label-face ; labels, case, public, private, proteced, namespace-tags
'font-lock-keyword-face)
(--copy-face 'font-lock-doc-markup-face ; comment markups such as Javadoc-tags
'font-lock-doc-face)
(--copy-face 'font-lock-doc-string-face ; comment markups
'font-lock-comment-face)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(font-lock-add-keywords
nil '(;; complete some fundamental keywords
("\\<\\(void\\|unsigned\\|signed\\|char\\|short\\|bool\\|int\\|long\\|float\\|double\\)\\>" . font-lock-keyword-face)
;; add the new C++11 keywords
("\\<\\(alignof\\|alignas\\|constexpr\\|noexcept\\|\\|static_assert\\|thread_local\\|override\\|final\\)\\>" . font-lock-keyword-face)
("\\<\\(decltype\\)\\>" . font-lock-builtin-face)
("\\<\\(nullptr\\)\\>" . font-lock-constant-face)
("\\<\\(char[0-9]+_t\\)\\>" . font-lock-keyword-face)
;; PREPROCESSOR_CONSTANT
("\\<[A-Z]+[A-Z_]+\\>" . font-lock-constant-face)
;; hexadecimal numbers
("\\<0[xX][0-9A-Fa-f]+\\>" . font-lock-constant-face)
;; integer/float/scientific numbers
("\\<[\\-+]*[0-9]*\\.?[0-9]+\\([ulUL]+\\|[eE][\\-+]?[0-9]+\\)?\\>" . font-lock-constant-face)
;; c++11 string literals
;; L"wide string"
;; L"wide string with UNICODE codepoint: \u2018"
;; u8"UTF-8 string", u"UTF-16 string", U"UTF-32 string"
("\\<\\([LuU8]+\\)\".*?\"" 1 font-lock-keyword-face)
;; R"(user-defined literal)"
;; R"( a "quot'd" string )"
;; R"delimiter(The String Data" )delimiter"
;; R"delimiter((a-z))delimiter" is equivalent to "(a-z)"
("\\(\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\)" 1 font-lock-keyword-face t) ; start delimiter
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(\\(.*?\\))[^\\s-\\\\()]\\{0,16\\}\"" 1 font-lock-string-face t) ; actual string
( "\\<[uU8]*R\"[^\\s-\\\\()]\\{0,16\\}(.*?\\()[^\\s-\\\\()]\\{0,16\\}\"\\)" 1 font-lock-keyword-face t) ; end delimiter
)))
;;###autoload
(add-hook 'c++-mode-hook 'c++1x-minor-mode)
(provide 'c++1x-minor-mode)

View File

@ -1,928 +0,0 @@
;;; doc-mode.el --- convenient editing of in-code documentation
;;
;; Copyright (C) 2007, 2009 Nikolaj Schumacher
;; Author: Nikolaj Schumacher <bugs * nschum de>
;; Version: 0.2
;; Keywords: convenience tools
;; URL: http://nschum.de/src/emacs/doc-mode/
;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x
;;
;; This file is NOT part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 2
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; This mode requires the Semantic package to be installed and running:
;; http://cedet.sourceforge.net/
;;
;; doc-mode allows easy creation and editing of JavaDoc or Doxygen comment
;; blocks in your code. It also greatly improves readability of code by folding
;; the blocks, so they don't take up precious screen lines.
;;
;; Add the following to your .emacs file:
;; (require 'doc-mode)
;; (add-hook 'c-mode-common-hook 'doc-mode)
;;
;; The command `doc-mode-fix-tag-doc' or "C-cdd" adds or replaces the
;; documentation for the function, variable, or class at point.
;; `doc-mode-remove-tag-doc' or "C-cdr" removes it.
;;
;; You can fold the comments by using `doc-mode-toggle-tag-doc-folding' or
;; `doc-mode-fold-all'.
;;
;;; Change Log:
;;
;; 2009-03-22 (0.2)
;; Added `doc-mode-keywords-from-tag-func' as customizable option.
;; Improved parameter list change recognition.
;; `doc-mode-jump-to-template' now enables jumping to the latest comment.
;; `doc-mode-first-template' now jumps to the first template in this buffer.
;;
;; 2007-09-09 (0.1.1)
;; Fixed return value detection.
;; Actual keyword highlighting.
;;
;; 2007-09-07 (0.1)
;; Initial release.
;;
;;; Code:
(eval-when-compile (require 'cl))
(require 'semantic)
(require 'cc-mode)
(require 'newcomment) ;comment-fill-column
(dolist (err `("^No tag found$" "^Semantic can't parse buffer$"
"^No template found$" "^doc-mode not enabled$"))
(add-to-list 'debug-ignored-errors err))
;; semantic-after-auto-parse-hooks
(defgroup doc-mode nil
"Minor mode for editing in-code documentation."
:group 'convenience
:group 'tools)
(defcustom doc-mode-auto-check-p t
"*Should the buffer documentation be checked after a Semantic reparse."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defcustom doc-mode-jump-to-template t
"*Should the point be moved inside the template after inserting a doc."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defcustom doc-mode-template-start "/**"
"*The string to insert at the beginning of a comment."
:group 'doc-mode
:type 'string)
(defcustom doc-mode-template-end " */"
"*The string to insert at the end of a comment."
:group 'doc-mode
:type 'string)
(defcustom doc-mode-template-continue " * "
"*The string to insert at the beginning of each line in a comment."
:group 'doc-mode
:type 'string)
(defcustom doc-mode-template-single-line-start "/** "
"*The string to insert at the beginning of a single-line comment.
For using single-line comments, see `doc-mode-allow-single-line-comments'"
:group 'doc-mode
:type 'string)
(defcustom doc-mode-template-single-line-end " */"
"*The string to insert at the end of a single-line comment.
For using single-line comments, see `doc-mode-allow-single-line-comments'"
:group 'doc-mode
:type 'string)
(defcustom doc-mode-template-keyword-char "@"
"*The character used to begin keywords."
:group 'doc-mode
:type '(choice (const :tag "@" "@")
(const :tag "\\" "\\")
(string :tag "Other")))
(defcustom doc-mode-template-empty-line-after-summary nil
"*Whether to put an empty line after the first one in the comment."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defcustom doc-mode-template-empty-line-before-keywords nil
"*Whether to put an empty line before the keyword list in a comment."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defcustom doc-mode-template-keywords
'("deprecated" "param" "return" "author" "exception" "throws" "version"
"since" "see" "sa" "todo")
"*Keywords that should be listed in this order.
All other keywords will be considered regular text."
:group 'doc-mode
:type '(repeat string))
(defcustom doc-mode-allow-single-line-comments t
"*Whether to allow a more space-saving format for very short comments.
When this is enabled, `doc-mode-template-single-line-start' and
`doc-mode-template-single-line-end' will be used to format single-line
comments instead of `doc-mode-template-start', `doc-mode-template-end' and
`doc-mode-template-continue'."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defcustom doc-mode-fold-single-line-comments nil
"*Whether to bother folding comments that are already a single line."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(const :tag "On" t)))
(defcustom doc-mode-align-keyword-arguments t
"*Whether to align the arguments to a keyword continued in the next line.
This may also be a number, describing how far to indent the argument list."
:group 'doc-mode
:type '(choice (const :tag "Off" nil)
(integer :tag "Indent" nil)
(const :tag "On" t)))
(defcustom doc-mode-fill-column nil
"*The column at which to break text when formatting it.
If this is nil, `comment-fill-column' is used."
:group 'doc-mode
:type '(choice (const :tag "Default" nil)
(integer :tag "Fill Column")))
(defcustom doc-mode-keywords-from-tag-func 'doc-mode-keywords-from-tag
"*Function used to generate keywords for a tag.
This must be a function that takes two arguments. The first argument is the
Semantic tag for which to generate keywords, the second is a list of existing
keywords taken from the current doc comment. It should return the new list of
keywords. Each element in a keyword list can be either a string or a list with
a keyword, optional argument and optional description. Additional entries with
undetermined content should be created with `doc-mode-new-keyword'."
:group 'doc-mode
:type 'function)
;;; keywords ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst doc-mode-font-lock-keywords
(eval-when-compile
`((,(concat "[\\@]"
(regexp-opt
'("addindex" "addtogroup" "anchor" "arg" "author" "brief" "callgraph"
"callergraph" "category" "code" "cond" "copydoc" "date" "defgroup"
"deprecated" "details" "dir" "dontinclude" "dot" "dotfile" "e"
"else" "elseif" "em" "endcode" "endcond" "enddot" "endhtmlonly"
"endif" "endlatexonly" "endlink" "endmanonly" "endmsc" "endverbatim"
"endxmlonly" "example" "f$" "f[" "f]" "file" "fn" "hideinitializer"
"htmlinclude" "htmlonly" "if" "ifnot" "image" "include"
"includelineno" "ingroup" "internal" "invariant" "latexonly" "li"
"line" "link" "mainpage" "manonly" "msc" "name" "nosubgrouping"
"note" "overload" "package" "page" "par" "paragraph" "post" "pre"
"private" "privatesection" "property" "protected" "protectedsection"
"public" "publicsection" "ref" "remarks" "return" "retval" "sa"
"section" "see" "serial" "serialData" "serialField"
"showinitializer" "since" "skip" "skipline" "subpage" "subsection"
"subsubsection" "test" "typedef" "until" "defvar" "verbatim"
"verbinclude" "version" "weakgroup" "xmlonly" "xrefitem" "$" "@"
"\\" "&" "~" "<" ">" "#" "%") t)
"\\>")
(0 font-lock-keyword-face prepend))
;; don't highlight \n, it's too common in code
("@n" (0 font-lock-keyword-face prepend))
(,(concat "\\([@\\]"
(regexp-opt '("class" "struct" "union" "exception" "enum" "throw"
"throws") t)
"\\)\\>\\(?:[ \t]+\\(\\sw+\\)\\)?")
(1 font-lock-keyword-face prepend)
(3 font-lock-type-face prepend))
(,(concat "\\([@\\]"
(regexp-opt '("param" "param[in]" "param[out]" "param[in+out]" "a"
"namespace" "relates" "relatesalso" "def") t)
"\\)\\>\\(?:[ \t]+\\(\\sw+\\)\\)?")
(1 font-lock-keyword-face prepend)
(3 font-lock-variable-name-face prepend))
(,(concat "\\([@\\]retval\\)\\>\\(?:[ \t]+\\(\\sw+\\)\\)?")
(1 font-lock-keyword-face prepend)
(2 font-lock-function-name-face prepend))
(,(concat "[@\\]" (regexp-opt '("attention" "warning" "todo" "bug") t)
"\\>")
(0 font-lock-warning-face prepend))
(,(concat "{@"
(regexp-opt '("docRoot" "inheritDoc" "link" "linkplain" "value") t)
"}")
(0 font-lock-keyword-face prepend))
("\\([@\\]b\\)[ \t\n]+\\([^ \t\n]+\\)"
(1 font-lock-keyword-face prepend)
(2 'bold prepend))
("\\([@\\]em?\\)[ \t\n]+\\([^ \t\n]+\\)"
(1 font-lock-keyword-face prepend)
(2 'italic prepend))
("\\([@\\][cp]\\)[ \t\n]+\\([^ \t\n]+\\)"
(1 font-lock-keyword-face prepend)
(2 'underline prepend)))))
;;; templates ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar doc-mode-templates nil)
(make-variable-buffer-local 'doc-mode-templates)
(defun doc-mode-add-template (beg end)
(let ((overlay (make-overlay beg (point))))
(overlay-put overlay 'intangible t)
(overlay-put overlay 'face 'highlight)
(overlay-put overlay 'insert-in-front-hooks '(doc-mode-replace-overlay))
(overlay-put overlay 'modification-hooks '(doc-mode-delete-overlay))
(push overlay doc-mode-templates)))
(defvar doc-mode-temp nil)
(defun doc-mode-delete-overlay (ov after-p beg end &optional r)
(unless after-p
(mapc 'doc-mode-unfold-by-overlay
(overlays-in (1- (overlay-start ov)) (1+ (overlay-end ov))))
(delete-overlay ov)
(setq doc-mode-templates (delq ov doc-mode-templates))))
(defun doc-mode-replace-overlay (ov after-p beg end &optional r)
(unless after-p
(let ((inhibit-modification-hooks nil))
(delete-region (overlay-start ov) (overlay-end ov)))))
;;;###autoload
(defun doc-mode-next-template (&optional pos limit)
"Jump to the next unfinished documentation template in this buffer."
(interactive)
(unless pos (setq pos (point)))
(unless limit (setq limit (point-max)))
(let ((min-start limit)
start)
(dolist (ov doc-mode-templates)
(setq start (overlay-start ov))
(and (> start pos)
(< start min-start)
(setq min-start start)))
(when (= min-start limit)
(error "End of buffer"))
(push-mark)
(goto-char min-start)))
;;;###autoload
(defun doc-mode-previous-template (&optional pos limit)
"Jump to the previous unfinished documentation template in this buffer."
(interactive)
(unless pos (setq pos (point)))
(unless limit (setq limit (point-min)))
(let ((max-start limit)
start)
(dolist (ov doc-mode-templates)
(setq start (overlay-start ov))
(and (< start pos)
(> start max-start)
(setq max-start start)))
(when (= max-start limit)
(error "Beginning of buffer"))
(push-mark)
(goto-char max-start)))
;;;###autoload
(defun doc-mode-first-template ()
"Jump to the first unfinished documentation template in this buffer."
(interactive)
(condition-case err
(doc-mode-next-template (point-min))
(error (error "No template found"))))
;;; mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar doc-mode-lighter " doc")
(defvar doc-mode-prefix-map
(let ((map (make-sparse-keymap)))
(define-key map "d" 'doc-mode-fix-tag-doc)
(define-key map "c" 'doc-mode-check-tag-doc)
(define-key map "t" 'doc-mode-toggle-tag-doc-folding)
(define-key map "f" 'doc-mode-fold-tag-doc)
(define-key map "u" 'doc-mode-unfold-tag-doc)
(define-key map "r" 'doc-mode-remove-tag-doc)
(define-key map "i" 'doc-mode-add-tag-doc)
(define-key map "e" 'doc-mode-next-faulty-doc)
(define-key map "n" 'doc-mode-next-template)
(define-key map "\C-c" 'doc-mode-check-buffer)
(define-key map "\C-f" 'doc-mode-fold-all)
(define-key map "\C-u" 'doc-mode-unfold-all)
map))
(defvar doc-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-d" doc-mode-prefix-map)
map)
"Keymap used for `doc-mode'.")
;;;###autoload
(define-minor-mode doc-mode
"Minor mode for editing in-code documentation."
nil doc-mode-lighter doc-mode-map
(if doc-mode
(progn
(font-lock-add-keywords nil doc-mode-font-lock-keywords)
(when doc-mode-auto-check-p
(add-hook 'semantic-after-auto-parse-hooks 'doc-mode-check-buffer
nil t)
(add-hook 'semantic-after-idle-scheduler-reparse-hooks
'doc-mode-check-buffer nil t)))
(dolist (ov doc-mode-templates)
(delete-overlay ov))
(kill-local-variable 'doc-mode-templates)
(doc-mode-unfold-all)
(font-lock-remove-keywords nil doc-mode-font-lock-keywords)
(remove-hook 'semantic-after-auto-parse-hooks 'doc-mode-check-buffer t)
(remove-hook 'semantic-after-idle-scheduler-reparse-hooks
'doc-mode-check-buffer t))
(when font-lock-mode
(font-lock-fontify-buffer)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun doc-mode-current-tag ()
(when (semantic-parse-tree-unparseable-p)
(error "Semantic can't parse buffer"))
(when (or (semantic-parse-tree-needs-rebuild-p)
(semantic-parse-tree-needs-update-p))
(condition-case nil
(semantic-fetch-tags)
(error (error "Semantic can't parse buffer"))))
(save-excursion
(or (semantic-current-tag-of-class 'function)
(semantic-current-tag-of-class 'variable)
(progn (beginning-of-line) (skip-chars-forward " \t\n") nil)
(semantic-current-tag-of-class 'function)
(semantic-current-tag-of-class 'variable)
(if (not (looking-at "/\\*\\*"))
(semantic-current-tag-of-class 'type)
(progn (search-forward "*/" nil t)
(skip-chars-forward " \t\n")
nil))
(semantic-current-tag-of-class 'function)
(semantic-current-tag-of-class 'variable)
(semantic-current-tag-of-class 'type))))
(defun doc-mode-current-tag-or-bust ()
(or (doc-mode-current-tag) (error "No tag found")))
;;; insertion ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun doc-mode-line-indent (keyword)
"Determine left side offset when indenting LINE."
(if (numberp doc-mode-align-keyword-arguments)
doc-mode-align-keyword-arguments
(+ 1 (length (car keyword))
(if (equal (car keyword) "param")
(1+ (length (cdr keyword)))
0))))
(defun doc-mode-insert (text)
"Insert TEXT if a string, or a template if 'prompt."
(if (stringp text)
(insert text)
(let ((beg (point)))
(insert (cadr text))
(when doc-mode
(doc-mode-add-template beg (point))))))
(defun doc-mode-insert-markup (markup &optional argument description)
(insert doc-mode-template-keyword-char markup)
(when argument
(insert " ")
(doc-mode-insert argument))
(when description
(insert " ")
(doc-mode-insert description)))
(defun doc-mode-insert-line (line indent)
(indent-to-column indent)
(let ((beg (point)))
(insert doc-mode-template-continue)
(if (and (consp line) (not (eq (car line) 'prompt)))
(apply 'doc-mode-insert-markup line)
(doc-mode-insert line))
(delete-char (- (skip-chars-backward " \t")))
(when (> (point) (+ beg 2))
(save-excursion (fill-region beg (point) 'left t)))
(insert "\n")))
(defun doc-mode-insert-keyword (keyword indent)
(indent-to-column indent)
(let ((fill-column (or doc-mode-fill-column comment-fill-column fill-column))
(fill-prefix (when doc-mode-align-keyword-arguments
(concat (buffer-substring (point-at-bol) (point))
doc-mode-template-continue
(make-string (doc-mode-line-indent keyword)
? )))))
(doc-mode-insert-line keyword indent)))
(defun doc-mode-insert-doc (keywords &optional pos)
"Insert a documentation at POS.
LINES is a list of keywords."
(save-excursion
(if pos
(goto-char pos)
(setq pos (point)))
(let ((indent (current-column)))
(if (and (not (cdr keywords)) doc-mode-allow-single-line-comments)
(progn (insert doc-mode-template-single-line-start)
(doc-mode-insert (car keywords))
(insert doc-mode-template-single-line-end "\n"))
(insert doc-mode-template-start "\n")
;; first line
(when (or (stringp (car keywords))
(eq 'prompt (caar keywords)))
(doc-mode-insert-line (pop keywords) indent))
(when (and doc-mode-template-empty-line-after-summary
(or (null doc-mode-template-empty-line-before-keywords)
(stringp (cadr keywords))))
(doc-mode-insert-line "" indent))
;; paragraphs
(if (cdr keywords)
(while (stringp (car keywords))
(doc-mode-insert-line (pop keywords) indent)
(when (stringp (car keywords))
(doc-mode-insert-line "" indent)))
(while (stringp (car keywords))
(doc-mode-insert-line (pop keywords) indent)))
(when doc-mode-template-empty-line-before-keywords
(doc-mode-insert-line "" indent))
;; keywords
(while keywords
(doc-mode-insert-keyword (pop keywords) indent))
(indent-to-column indent)
(insert doc-mode-template-end "\n"))
;; re-indent original line
(if (< (current-column) indent)
(indent-to-column indent)
(move-to-column indent t))))
(and doc-mode-jump-to-template doc-mode-templates
(ignore-errors (doc-mode-next-template pos (point)))))
(defun doc-mode-remove-doc (point)
"Remove the documentation before POINT."
(let* ((bounds (doc-mode-find-doc-bounds point))
(beg (plist-get bounds :beg))
(end (plist-get bounds :end)))
(when bounds
(save-excursion
(goto-char beg)
(incf beg (skip-chars-backward " \t"))
(goto-char end)
(incf end (skip-chars-forward " \t"))
(when (eolp) (incf end))
(delete-region beg end)))))
;;;###autoload
(defun doc-mode-remove-tag-doc (tag)
"Remove the documentation for TAG.
If called interactively, use the tag given by `doc-mode-current-tag'."
(interactive (list (doc-mode-current-tag-or-bust)))
(doc-mode-remove-doc (semantic-tag-start tag)))
;;; registering ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun doc-mode-find-doc-bounds (pos)
"Find the documentation right before POS.
If there is anything but whitespace between the documentation and POS, nil is
returned. Otherwise a cons of the doc's beginning and end is given."
(let (end)
(save-excursion
(goto-char pos)
(when (re-search-backward "[ \t]*\n[ \t]*\\=" nil t)
(setq end (point))
(cond
;; /// Doxygen comment */
((looking-back "[ \t]*//[/!]\\(.*\\)$")
(forward-line -1)
(while (looking-at "[ \t]*//[/!]\\(.*\\)$")
(forward-line -1))
(forward-line 1)
(skip-chars-forward " \t")
`(:beg ,(point) :end ,end :column ,(current-indentation)))
;; /** JavaDoc comment */