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

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

problem with "comment-auto-fill-only-comments"


From: michael-franzese
Subject: problem with "comment-auto-fill-only-comments"
Date: Sat, 30 Jan 2021 13:51:15 +0100

I am having problem with the following code.  I cannot locate the
problem though.

;; Break lines using auto-fill made.
(defun break-comments-din ()
  "Break lines when they exceed a specific character length."
  (setq-local comment-auto-fill-only-comments t))

(defvar dfv-break-comments-state nil)

;; Cycles line breaking tool
(defun cycle-break-comments-din ()
  "Break comments in programming languages."

  (pcase dfv-break-comments-state
    ;;
    (1 (auto-fill-mode 1)
       (add-hook 'sh-mode-hook          #'break-comments-din)
       (add-hook 'fortran-mode-hook     #'break-comments-din)
       (add-hook 'emacs-lisp-mode-hook  #'break-comments-din)
       (add-hook 'c-mode-hook           #'break-comments-din)
       (add-hook 'c++-mode-hook         #'break-comments-din)
       (add-hook 'awk-mode-hook         #'break-comments-din)
       (add-hook 'R-mode-hook           #'break-comments-din)
       (add-hook 'octave-mode-hook      #'break-comments-din)
       (setq dfv-break-comments-state 2)
       (message "%s" "Enable: Break comments"))
    ;;
    (2 (auto-fill-mode 0)
       (setq dfv-break-comments-state 0)
       (message "%s" "Disable: Break comments"))
    ;;
    (_ (auto-fill-mode 1)
       (add-hook 'prog-mode-hook #'break-comments-din)
       (setq dfv-break-comments-state 1)
       (message "%s" "Break comments using prog-mode-hook")) )

  ;; Break comments  Keybinding for breaking comments using Auto Fill
  (add-hook 'texinfo-mode-hook  #'break-comment-din)
  (add-hook 'text-mode-hook     #'break-comment-din)
  (global-set-key (kbd "C-c q") #'break-comment-din) )






reply via email to

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