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

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

Re: problems with auto-fill-mode


From: jai-bholeki
Subject: Re: problems with auto-fill-mode
Date: Sat, 30 Jan 2021 17:54:29 +0100

Does it matter which expression to call first.

 (setq fill-column 72)
 (auto-fill-mode)

or

 (auto-fill-mode)
 (setq fill-column 72)


> Sent: Sunday, January 31, 2021 at 4:36 AM
> From: jai-bholeki@gmx.com
> To: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: problems with auto-fill-mode
>
> I am having a lot of problems on how to set up  auto-fill-mode.
>
> I want to cycle auto-fill of comments, then disable them using
> the keybinding "C-c q".
>
> Have written the following code.
>
> (defun break-comments ()
>   "Break lines when they exceed a specific character length."
>   (setq-local comment-auto-fill-only-comments t))
>
> (defun fill-break-comments ()
>   "Break lines when they exceed a specific character length."
>   (setq fill-column 72)
>   (setq-local comment-auto-fill-only-comments t)
>   (auto-fill-mode 0) )
>
> (defvar dfv-break-comments-state nil)
>
> ;; Cycles line breaking tool
> (defun cycle-break-comments ()
>   "Break comments in programming languages."
>   (interactive)
>
>   (pcase dfv-break-comments-state
>     ;;
>     (1 (setq-local comment-auto-fill-only-comments nil)
>        (auto-fill-mode 0)
>        (setq dfv-break-comments-state 0)
>        (message "%s" "Disable: Break comments"))
>     ;;
>     (_ (setq fill-column 72)
>        (if (not nil dfv-break-comments-state)
>          (add-hook 'prog-mode-hook #'break-comments)
>        (progn
>          (add-hook 'sh-mode-hook          #'break-comments)
>          (add-hook 'fortran-mode-hook     #'break-comments)
>          (add-hook 'emacs-lisp-mode-hook  #'break-comments)
>          (add-hook 'c-mode-hook           #'break-comments)
>          (add-hook 'c++-mode-hook         #'break-comments)
>            (add-hook 'awk-mode-hook         #'break-comments)
>          (add-hook 'R-mode-hook           #'break-comments)
>          (add-hook 'octave-mode-hook      #'break-comments)
>          ;;
>          (add-hook 'texinfo-mode-hook  #'break-comments)
>          (add-hook 'text-mode-hook     #'break-comments))
>        (auto-fill-mode))
>        ;;
>        (setq dfv-break-comments-state 1)
>        (message "%s" "Break comments using prog-mode-hook")) )
>
>   ;; Break comments using auto-fill
>   (global-set-key (kbd "C-c q") #'cycle-break-comments) )
>
>
>
>
>
>
>



reply via email to

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