;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/ide/ide.el (require 'mode-line) (require 'quit) (require 'super) (require 'w3m-url) (defun find-conf-key (key &optional beg end) (interactive (let ((ps "[key]")) (if (use-region-p) (list (read-key ps) (region-beginning) (region-end)) (list (read-key ps))))) (or beg (setq beg (point-min))) (or end (setq end (point-max))) (let*((re (char-to-string key)) (count (how-many re beg end))) (if (zerop count) (message "no hits!") (re-search-forward re end nil) (message "total: %d" count)))) (defun this-file-comment (&optional here) (interactive "P") (let ((pos (point)) (beg (point-min)) (lbl "this file:\n") (url "https://dataswamp.org/~incal/")) (unless here (goto-char beg)) (insert (format "%s %s%s\n\n" lbl url (string-remove-prefix "public_html/" (string-remove-prefix ".emacs.d/" (string-remove-prefix "/home/incal/" buffer-file-name))))) (comment-region beg (point)) (forward-char (1- pos)) (save-buffer))) (defalias 'tf #'this-file-comment) ;; Makefile (require 'make-mode) (keymap-set makefile-mode-map "C-c C-c" #'compile) ;; Prolog (defun prolog-mode-hook-f () (lines)) (add-hook 'prolog-mode-hook #'prolog-mode-hook-f) ;; CSS (require 'css-mode) (setq css-fontify-colors nil) (defun css-mode-hook-f () (lines)) (add-hook 'css-mode-hook #'css-mode-hook-f) ;; markdown (require 'markdown-mode) (defun markdown-mode-hook-f () (auto-fill-mode 1) (lines) (let ((kmap markdown-mode-map)) (disable-super-global-keys kmap) (keymap-set kmap "C-c C-c" #'compile))) (add-hook 'markdown-mode-hook #'markdown-mode-hook-f) ;; nroff. [man pages, ./man-incal.el] (require 'nroff-mode) (defun nroff-mode-hook-f () (auto-fill-mode -1) (lines) (let ((kmap nroff-mode-map)) (disable-super-global-keys kmap) (keymap-set kmap "C-c C-c" #'compile) (keymap-set kmap "C-o ;" #'nroff-view))) (add-hook 'nroff-mode-hook #'nroff-mode-hook-f) ;; Perl (defun perl-mode-hook-f () (lines)) (add-hook 'perl-mode-hook #'perl-mode-hook-f) ;; shell (sh) (defun awk-col (col) (interactive "scolumn: ") (insert (format "awk '{print $%s}'" col))) ;; XML (defun nxml-mode-hook-f () (visual-line-mode -1)) (add-hook 'nxml-mode-hook #'nxml-mode-hook-f) ;; conf mode (defun conf-mode-hook-f () (lines)) (add-hook 'conf-mode-hook #'conf-mode-hook-f) ;; gnuplot-mode (defun gnuplot-mode-hook-f () (lines)) (add-hook 'gnuplot-mode-hook #'gnuplot-mode-hook-f) (provide 'ide)