.emacs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. (server-start)
  2. (tool-bar-mode 0)
  3. (menu-bar-mode 0)
  4. (scroll-bar-mode 0)
  5. (load-theme 'solarized-dark)
  6. (linum-mode 1)
  7. (setq time-stamp-pattern "-10/Last updated: [\"<]%:y-%02m-%02d %02H:%02M:%02S %Z[\">]")
  8. (add-hook 'before-save-hook 'time-stamp)
  9. (put 'downcase-region 'disabled nil)
  10. (setq inhibit-splash-screen t)
  11. (column-number-mode 1)
  12. (put 'narrow-to-region 'disabled nil)
  13. ;; disable backup
  14. (setq backup-inhibited t)
  15. (setq make-backup-files nil)
  16. (setq auto-save-default nil) ; disable autosave
  17. ;; From
  18. ;; https://mcmackins.org/dl/configs/emacs
  19. (require 'web-mode)
  20. (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "https://marmalade-repo.org/packages/")))
  21. (if (fboundp 'gnutls-available-p)
  22. (fmakunbound 'gnutls-available-p))
  23. (setq tls-program '("gnutls-cli --tofu -p %p %h")
  24. imap-ssl-program '("gnutls-cli --tofu -p %p %s")
  25. smtpmail-stream-type 'starttls
  26. starttls-extra-arguments '("--tofu")
  27. )
  28. (put 'upcase-region 'disabled nil)
  29. (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
  30. (add-to-list 'custom-theme-load-path "~/.emacs.d/lisp")
  31. (custom-set-variables
  32. ;; custom-set-variables was added by Custom.
  33. ;; If you edit it by hand, you could mess it up, so be careful.
  34. ;; Your init file should contain only one such instance.
  35. ;; If there is more than one, they won't work right.
  36. '(custom-safe-themes
  37. (quote
  38. ("a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" default))))
  39. (custom-set-faces
  40. ;; custom-set-faces was added by Custom.
  41. ;; If you edit it by hand, you could mess it up, so be careful.
  42. ;; Your init file should contain only one such instance.
  43. ;; If there is more than one, they won't work right.
  44. )
  45. (eval-after-load 'sgml-mode
  46. '(add-hook 'html-mode-hook (lambda ()
  47. (set (make-local-variable 'time-stamp-pattern)
  48. "-8/<p>Last updated: %:y-%02m-%02d %02H:%02M:%02S %Z.</p>")
  49. )))
  50. (setq time-stamp-pattern "-8/<p>Last updated: %:y-%02m-%02d %02H:%02M:%02S %Z.</p>")
  51. (defun xah-title-case-region-or-line (@begin @end)
  52. "Title case text between nearest brackets, or current line, or text selection.
  53. Capitalize first letter of each word, except words like {to, of, the, a, in, or, and, …}. If a word already contains cap letters such as HTTP, URL, they are left as is.
  54. When called in a elisp program, *begin *end are region boundaries.
  55. URL `http://ergoemacs.org/emacs/elisp_title_case_text.html'
  56. Version 2017-01-11"
  57. (interactive
  58. (if (use-region-p)
  59. (list (region-beginning) (region-end))
  60. (let (
  61. $p1
  62. $p2
  63. ($skipChars "^\"<>(){}[]“”‘’‹›«»「」『』【】〖〗《》〈〉〔〕"))
  64. (progn
  65. (skip-chars-backward $skipChars (line-beginning-position))
  66. (setq $p1 (point))
  67. (skip-chars-forward $skipChars (line-end-position))
  68. (setq $p2 (point)))
  69. (list $p1 $p2))))
  70. (let* (
  71. ($strPairs [
  72. [" A " " a "]
  73. [" And " " and "]
  74. [" At " " at "]
  75. [" As " " as "]
  76. [" By " " by "]
  77. [" Be " " be "]
  78. [" Into " " into "]
  79. [" In " " in "]
  80. [" Is " " is "]
  81. [" It " " it "]
  82. [" For " " for "]
  83. [" Of " " of "]
  84. [" Or " " or "]
  85. [" On " " on "]
  86. [" Via " " via "]
  87. [" The " " the "]
  88. [" That " " that "]
  89. [" To " " to "]
  90. [" Vs " " vs "]
  91. [" With " " with "]
  92. [" From " " from "]
  93. ["'S " "'s "]
  94. ["'T " "'t "]
  95. ]))
  96. (save-excursion
  97. (save-restriction
  98. (narrow-to-region @begin @end)
  99. (upcase-initials-region (point-min) (point-max))
  100. (let ((case-fold-search nil))
  101. (mapc
  102. (lambda ($x)
  103. (goto-char (point-min))
  104. (while
  105. (search-forward (aref $x 0) nil t)
  106. (replace-match (aref $x 1) "FIXEDCASE" "LITERAL")))
  107. $strPairs))))))