From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Thorpe Newsgroups: gmane.emacs.help Subject: Re: Indenting with spaces rather than tabs Date: Sun, 31 Jan 2021 06:02:39 +0000 Message-ID: <87sg6hiqyo.fsf@robertthorpeconsulting.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34204"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: wael-zwaiter@gmx.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 31 07:03:59 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l65q3-0008me-2B for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 31 Jan 2021 07:03:59 +0100 Original-Received: from localhost ([::1]:37488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l65q0-0006Re-6e for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 31 Jan 2021 01:03:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l65pN-0006R4-Te for help-gnu-emacs@gnu.org; Sun, 31 Jan 2021 01:03:21 -0500 Original-Received: from outbound-smtp54.blacknight.com ([46.22.136.238]:37975) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l65pJ-0003IF-E5 for help-gnu-emacs@gnu.org; Sun, 31 Jan 2021 01:03:17 -0500 Original-Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp54.blacknight.com (Postfix) with ESMTPS id 321DB1061E1 for ; Sun, 31 Jan 2021 06:03:10 +0000 (GMT) Original-Received: (qmail 4002 invoked from network); 31 Jan 2021 06:03:09 -0000 Original-Received: from unknown (HELO rt-inspiron-3480) (rt@robertthorpeconsulting.com@[109.76.74.4]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 31 Jan 2021 06:03:09 -0000 In-Reply-To: (wael-zwaiter@gmx.com) Received-SPF: pass client-ip=46.22.136.238; envelope-from=rt@robertthorpeconsulting.com; helo=outbound-smtp54.blacknight.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127468 Archived-At: wael-zwaiter@gmx.com writes: > 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) I'm not sure what you're trying to do. I don't see how your code can cycle things. You always add this hooks, and you never take them away. Also, I think that pcase always runs the case "_". I may be wrong, since I don't use it. BR, Robert Thorpe