help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

whitespace in comment-start


From: Emanuel Berg
Subject: whitespace in comment-start
Date: Sat, 01 May 2021 17:51:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Check out the 2nd comment block below...

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/latex.el
;;;   https://dataswamp.org/~incal/emacs-init/latex.el

(require 'mode-line)
(require 'super)
(require 'tex-mode)

(defun last-char-of-string (str)
  (string-to-char (substring str -1)) )

;; note creative use of `concat' and `unless' as (concat "a" nil "b") ; "ab"
;; last char comparison so that it'll be "; done" in emacs-lisp, but
;; "<!-- done -->" in markdown (and not "<!--  done -->")
;; however why is the whitespace there in markdown to begin with?

(defun find-here ()
  (interactive)
  (let ((start (point)))
    (goto-char (point-min))
    (let*((sign (concat
                 comment-start
                 (unless (= (last-char-of-string comment-start) ?\  ) " ")
                 "done"
                 comment-end))
          (hits (how-many sign (point-min) (point-max))) )
      (if (> hits 0)
          (progn
            (search-forward-regexp sign)
            (beginning-of-line)
            (recenter 1)
            (message "%d" hits) )
        (goto-char start)
        (insert sign) ))))
(defalias 'h #'find-here)

(defun set-latex-keys ()
  (let ((the-map latex-mode-map))
    (disable-super-global-keys the-map)
    (define-key the-map "\C-c\C-c" #'compile) ))

;; (setq latex-mode-hook nil)
(defun latex-mode-hook-f ()
  (set-latex-keys)
  (auto-fill-mode)
  (abbrev-mode)
  (lines) )
(add-hook 'latex-mode-hook #'latex-mode-hook-f)

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]