From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime Newsgroups: gmane.emacs.help Subject: Re: Printing comment-start of various modes Date: Tue, 13 Aug 2024 22:10:50 +0000 Message-ID: <2l_xLd12dh_ZujM5MghWm1fLbHkxd5vCW1oqk6SxVwtbzfFJqzPDzp1edZUNRhm0y-tdS9pch7wRy9Gnx7LzpGE94Q7g00ecuza2NFGjapA=@protonmail.com> References: <875xs486sq.fsf@gmx.net> <871q2s84w6.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12602"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 14 00:11:43 2024 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 1sdzjz-0003AA-9x for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 14 Aug 2024 00:11:43 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sdzjG-0007AL-Bx; Tue, 13 Aug 2024 18:10:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdzjE-00079w-F0 for help-gnu-emacs@gnu.org; Tue, 13 Aug 2024 18:10:56 -0400 Original-Received: from mail-40140.protonmail.ch ([185.70.40.140]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sdzjC-0004hf-CK for help-gnu-emacs@gnu.org; Tue, 13 Aug 2024 18:10:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1723587051; x=1723846251; bh=ezq+F8jN6DG4/0bRqiizerwb3JksvuVmvfoVnmBjpxo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=i4vQtMO7dONvw7UAAEAgRPnjlIqodL8sl7PFhBJpF1zFT6MMFxOH8TnIO3fxrafik ReRBWoV/9IZ/rX8ITxtKAT8cGNd22fauehEMR8lNHhEmiZ7odQ3z0ueL7dGOfSjGHH Q33TQT+z1iQN6z01SuGhsiozZ1IvFolhUdwMpS8q6lGPxRI8MrDV7WSSArRajQez2A eK88mHixYv9HnPN+KVOslHankksgz+QC+pWoi2KkCdO7yh9Athl0hd4t4VpFUxbUEu vwcbpSR3uS/Nx+B2Bo5PsFdxuTI1UUTHIJP/Tm+lhYa+Sy2/xiXVBVxbYLRAxSui2F P32uwDSE55G8Q== In-Reply-To: <871q2s84w6.fsf@gmx.net> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 8ee25bc37ee1caf4514b4a3e00ee00ad87f8aaf3 Received-SPF: pass client-ip=185.70.40.140; envelope-from=heimeborgia@protonmail.com; helo=mail-40140.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:147665 Archived-At: Sent with Proton Mail secure email. On Wednesday, August 14th, 2024 at 9:55 AM, Stephen Berman wrote: > On Tue, 13 Aug 2024 21:32:50 +0000 Heime heimeborgia@protonmail.com wrote= : >=20 > > Sent with Proton Mail secure email. > >=20 > > On Wednesday, August 14th, 2024 at 9:13 AM, Stephen Berman > > stephen.berman@gmx.net wrote: > >=20 > > > On Tue, 13 Aug 2024 20:09:57 +0000 Heime heimeborgia@protonmail.com w= rote: > > >=20 > > > > This function should print the value of comment-start for various m= odes, > > > > but I am not getting any comment-start outputs from it. > > > >=20 > > > > (defun costart () > > > > "Loop through various major modes and print the value of `comment-s= tart`." > > > >=20 > > > > (interactive) > > > >=20 > > > > (let ( (modes '(sh-mode perl-mode python-mode > > > > emacs-lisp-mode lisp-interaction-mode > > > > org-mode tex-mode latex-mode texi-mode > > > > c-mode c++-mode f90-mode fortran-mode > > > > html-mode css-mode js-mode > > > > java-mode php-mode) ) > > > >=20 > > > > (output-buffer (generate-new-buffer "Costart")) ) > > > >=20 > > > > (with-current-buffer output-buffer > > > > (insert "Mode \t\t Comment Start \n") > > > > (insert "---- \t\t ------------- \n")) > > > >=20 > > > > (dolist (mode modes) > > > > (with-temp-buffer > > > > (funcall mode) > > > > (let ((comment-start (or comment-start "None"))) > > > > (with-current-buffer output-buffer > > > > (insert (format "%s \t\t %s \n" mode comment-start)))))) > > > >=20 > > > > (switch-to-buffer output-buffer))) > > >=20 > > > You successively bind mode-specific value of comment-start in a > > > temporary buffer, and then switch to output-buffer to print the value= s, > > > but this buffer is in fundamental-mode, where comment-start has the > > > value nil by default. Using the temporary buffer seems superfluous, y= ou > > > could just use output-buffer: > > >=20 > > > (defun costart () > > > "Loop through various major modes and print the value of `comment-sta= rt`." > > > (interactive) > > > (let ((modes '(sh-mode perl-mode python-mode > > > emacs-lisp-mode lisp-interaction-mode > > > org-mode tex-mode latex-mode texi-mode > > > c-mode c++-mode f90-mode fortran-mode > > > html-mode css-mode js-mode > > > java-mode php-mode) ) > > > (output-buffer (generate-new-buffer "Costart"))) > > > (with-current-buffer output-buffer > > > (insert "Mode \t\t Comment Start \n") > > > (insert "---- \t\t ------------- \n")) > > > (dolist (mode modes) > > > (with-current-buffer output-buffer > > > (funcall mode) > > > (let ((comment-start (or comment-start "None"))) > > > (insert (format "%s \t\t %s \n" mode comment-start))))) > > > (switch-to-buffer output-buffer) > > > (fundamental-mode))) > > >=20 > > > Steve Berman > >=20 > > What does it matter if the buffer is in fundamental-mode, when I am cha= nging > > the major mode ? I still do not get the dolist insert for each mode. >=20 >=20 > With the code I posted, I get this output (I evaluated and executed the > code after commenting out texi-mode and php-mode, because they were not > loaded in my running Emacs): >=20 > Mode Comment Start > ---- ------------- > sh-mode # > perl-mode # > python-mode # > emacs-lisp-mode ; > lisp-interaction-mode ; > org-mode # > tex-mode % > latex-mode % > c-mode /* > c++-mode // > f90-mode ! > fortran-mode C > html-mode