.emacs.d/init.d/text/web.el

72 lines
2.7 KiB
EmacsLisp

;;; web.el --- Settings for web stuff. -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'basics/package-management)
(require 'misc/completion)
;; Disable, because LSP does it better(?).
;; ;; Use company auto-completion for (X)HTML.
;; (use-package company-web
;; :demand t
;; :after (company)
;; :config (add-to-list 'company-backends 'company-web-html))
(use-package web-mode
:custom
(web-mode-markup-indent-offset 2) ; Default indentation level.
:config (progn
(defun my/html-surround-with-tag (beg end)
"Surround region with HTML tag."
(interactive "r")
(if (region-active-p)
(let ((tag (completing-read "Tag: "
'("blockquote" "em" "strong"))))
(insert (concat "<" tag ">"
(delete-and-extract-region beg end)
"</" tag ">")))
(message "No active region")))
(defun my/html-paragraphify-buffer ()
"Wrap every line not beginning with < or a newline in <p> tags."
(interactive)
(goto-char (point-min))
(while (re-search-forward "^\\([^<
].+\\)$" nil t)
(replace-match "<p>\\1</p>"))))
:mode (("\\.[ps]?html?$" . web-mode)
("\\.tmpl$" . web-mode) ; Gitea templates.
("\\.php$" . web-mode))
:hook (web-mode . (lambda () (set-fill-column 120)))
:bind ("C-c C-M-h" . my/html-surround-with-tag))
;; Read EPUB ebooks.
(use-package nov
:custom (nov-text-width fill-column)
:custom-face (variable-pitch ((t (:inherit variable-pitch
:family "Source Serif Pro"
:height 1.4))))
:mode ("\\.epub$" . nov-mode))
;; Mode for writing blog posts with hugo.
(when (string= (system-name) "ventiloplattform")
(use-package easy-hugo
:custom ((easy-hugo-basedir "~/Projekte/www/thoughtpile.tastytea.de/")
(easy-hugo-url "https://thoughtpile.tastytea.de")
(easy-hugo-postdir "content/posts")
(easy-hugo-previewtime (* 60 60 2))
(easy-hugo-default-ext ".adoc")
(easy-hugo-asciidoc-extension "adoc")
(easy-hugo-server-flags "-D")
(easy-hugo-bloglist ; Additional blogs.
'(((easy-hugo-basedir . "~/Projekte/www/text-de.tastytea.de/")
(easy-hugo-url . "https://text-de.tastytea.de")
(easy-hugo-postdir . "content/posts")
(easy-hugo-previewtime . (* 60 60 2))))))
:bind ("C-c h" . easy-hugo)))
(provide 'text/web)
;;; web.el ends here