[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Indenting with spaces rather than tabs
From: |
wael-zwaiter |
Subject: |
Re: Indenting with spaces rather than tabs |
Date: |
Sat, 30 Jan 2021 20:25:47 +0100 |
I am having problems with this code
(defun break-comments ()
"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 ()
"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)
(auto-fill-mode)
(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)
;;
(setq dfv-break-comments-state 1)
(message "%s" "Break comments using prog-mode-hook")) ))
;; Break comments using auto-fill
(global-set-key (kbd "H-q") #'cycle-break-comments)
> Sent: Sunday, January 31, 2021 at 6:46 AM
> From: "Robert Thorpe" <rt@robertthorpeconsulting.com>
> To: wael-zwaiter@gmx.com
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: Indenting with spaces rather than tabs
>
> wael-zwaiter@gmx.com writes:
>
> > Can I do as follows, so that tabs are removed when "dfv-untabify-state"
> > is "true".
> >
> > (defvar dfv-untabify-state nil)
> > (defun clean-before-save ()
> > "Removes trailing spaces and tabs upon exiting"
> >
> > (delete-trailing-whitespace)
> > (when (dfv-untabify-state)
> > (unless (member major-mode '(makefile-gmake-mode makefile-mode))
> > (untabify (point-min) (point-max))) ))
>
> Yes you can do that. I think Mr.Berg gave some similar code in this
> thread.
>
> Be careful though about accidentally wrecking files. I notice you've
> exempted makefiles, which is a good idea. You might want to exempt
> more, like config files.
>
> If you're doing work on a VC system with others then changing tabs
> becomes a major irritation. That's because it creates a lot of false
> changes (i.e. line changes where the code hasn't really changed).
>
> BR,
> Robert Thorpe
>
>