diff options
Diffstat (limited to 'tag-emacs')
-rw-r--r-- | tag-emacs/emacs.d/init.el | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el index 0f7c8862..a407ecc3 100644 --- a/tag-emacs/emacs.d/init.el +++ b/tag-emacs/emacs.d/init.el @@ -1172,6 +1172,74 @@ symbol, not word, as I need this for programming the most." ("M-Z" . zap-to-char))) (req-package typopunct + :config (progn + (defconst typopunct-minus (decode-char 'ucs #x2212)) + (defadvice typopunct-insert-typographical-dashes + (around minus-or-pm activate) + (cond + ((or (eq (char-before) typopunct-em-dash) + (looking-back "\\([[:blank:]]\\|^\\)\\^")) + (delete-char -1) + (insert typopunct-minus)) + ((looking-back "[^[:blank:]]\\^") + (insert typopunct-minus)) + (t ad-do-it))) + (define-key typopunct-map "+" 'typopunct-insert-mp) + + (defconst typopunct-ellipsis (decode-char 'ucs #x2026)) + (defconst typopunct-middot (decode-char 'ucs #xB7)) ; or 2219 + (defun typopunct-insert-ellipsis-or-middot (arg) + "Change three consecutive dots to a typographical ellipsis mark." + (interactive "p") + (cond + ((and (= 1 arg) + (eq (char-before) ?^)) + (delete-char -1) + (insert typopunct-middot)) + ((and (= 1 arg) + (eq this-command last-command) + (looking-back "\\.\\.")) + (replace-match "") + (insert typopunct-ellipsis)) + (t + (self-insert-command arg)))) + (define-key typopunct-map "." 'typopunct-insert-ellipsis-or-middot) + + (defconst typopunct-times (decode-char 'ucs #xD7)) + (defun typopunct-insert-times (arg) + (interactive "p") + (if (and (= 1 arg) (looking-back "\\([[:blank:]]\\|^\\)\\^")) + (progn (delete-char -1) + (insert typopunct-times)) + (self-insert-command arg))) + (define-key typopunct-map "x" 'typopunct-insert-times) + + (defadvice typopunct-insert-quotation-mark (around wrap-region activate) + (let* ((lang (or (get-text-property (point) 'typopunct-language) + typopunct-buffer-language)) + (omark (if single + (typopunct-opening-single-quotation-mark lang) + (typopunct-opening-quotation-mark lang))) + (qmark (if single + (typopunct-closing-single-quotation-mark lang) + (typopunct-closing-quotation-mark lang)))) + (cond + (mark-active + (let ((skeleton-end-newline nil) + (singleo (typopunct-opening-single-quotation-mark lang)) + (singleq (typopunct-closing-single-quotation-mark lang))) + (if (> (point) (mark)) + (exchange-point-and-mark)) + (save-excursion + (while (re-search-forward (regexp-quote (string omark)) (mark) t) + (replace-match (regexp-quote (string singleo)) nil nil))) + (save-excursion + (while (re-search-forward (regexp-quote (string qmark)) (mark) t) + (replace-match (regexp-quote (string singleq)) nil nil))) + (skeleton-insert (list nil omark '_ qmark) -1))) + ((looking-at (regexp-opt (list (string omark) (string qmark)))) + (forward-char 1)) + (t ad-do-it))))) :init (progn (typopunct-change-language 'english t) (add-hook 'text-mode-hook #'typopunct-mode))) |