* Printing comment-start of various modes
@ 2024-08-13 20:09 Heime
2024-08-13 21:13 ` Stephen Berman
0 siblings, 1 reply; 7+ messages in thread
From: Heime @ 2024-08-13 20:09 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
This function should print the value of comment-start for various modes,
but I am not getting any comment-start outputs from it.
(defun costart ()
"Loop through various major modes and print the value of `comment-start`."
(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-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))))))
(switch-to-buffer output-buffer)))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing comment-start of various modes
2024-08-13 20:09 Printing comment-start of various modes Heime
@ 2024-08-13 21:13 ` Stephen Berman
2024-08-13 21:32 ` Heime
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2024-08-13 21:13 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
On Tue, 13 Aug 2024 20:09:57 +0000 Heime <heimeborgia@protonmail.com> wrote:
> This function should print the value of comment-start for various modes,
> but I am not getting any comment-start outputs from it.
>
> (defun costart ()
> "Loop through various major modes and print the value of `comment-start`."
>
> (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-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))))))
>
> (switch-to-buffer output-buffer)))
You successively bind mode-specific value of comment-start in a
temporary buffer, and then switch to output-buffer to print the values,
but this buffer is in fundamental-mode, where comment-start has the
value nil by default. Using the temporary buffer seems superfluous, you
could just use output-buffer:
(defun costart ()
"Loop through various major modes and print the value of `comment-start`."
(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)))
Steve Berman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing comment-start of various modes
2024-08-13 21:13 ` Stephen Berman
@ 2024-08-13 21:32 ` Heime
2024-08-13 21:55 ` Stephen Berman
0 siblings, 1 reply; 7+ messages in thread
From: Heime @ 2024-08-13 21:32 UTC (permalink / raw)
To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor
Sent with Proton Mail secure email.
On Wednesday, August 14th, 2024 at 9:13 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Tue, 13 Aug 2024 20:09:57 +0000 Heime heimeborgia@protonmail.com wrote:
>
> > This function should print the value of comment-start for various modes,
> > but I am not getting any comment-start outputs from it.
> >
> > (defun costart ()
> > "Loop through various major modes and print the value of `comment-start`."
> >
> > (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-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))))))
> >
> > (switch-to-buffer output-buffer)))
>
>
> You successively bind mode-specific value of comment-start in a
> temporary buffer, and then switch to output-buffer to print the values,
> but this buffer is in fundamental-mode, where comment-start has the
> value nil by default. Using the temporary buffer seems superfluous, you
> could just use output-buffer:
>
> (defun costart ()
> "Loop through various major modes and print the value of `comment-start`."
> (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)))
>
> Steve Berman
What does it matter if the buffer is in fundamental-mode, when I am changing
the major mode ? I still do not get the dolist insert for each mode.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing comment-start of various modes
2024-08-13 21:32 ` Heime
@ 2024-08-13 21:55 ` Stephen Berman
2024-08-13 22:10 ` Heime
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2024-08-13 21:55 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
On Tue, 13 Aug 2024 21:32:50 +0000 Heime <heimeborgia@protonmail.com> wrote:
> Sent with Proton Mail secure email.
>
> On Wednesday, August 14th, 2024 at 9:13 AM, Stephen Berman
> <stephen.berman@gmx.net> wrote:
>
>> On Tue, 13 Aug 2024 20:09:57 +0000 Heime heimeborgia@protonmail.com wrote:
>>
>> > This function should print the value of comment-start for various modes,
>> > but I am not getting any comment-start outputs from it.
>> >
>> > (defun costart ()
>> > "Loop through various major modes and print the value of `comment-start`."
>> >
>> > (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-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))))))
>> >
>> > (switch-to-buffer output-buffer)))
>>
>>
>> You successively bind mode-specific value of comment-start in a
>> temporary buffer, and then switch to output-buffer to print the values,
>> but this buffer is in fundamental-mode, where comment-start has the
>> value nil by default. Using the temporary buffer seems superfluous, you
>> could just use output-buffer:
>>
>> (defun costart ()
>> "Loop through various major modes and print the value of `comment-start`."
>> (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)))
>>
>> Steve Berman
>
> What does it matter if the buffer is in fundamental-mode, when I am changing
> the major mode ? I still do not get the dolist insert for each mode.
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):
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 <!--
css-mode /*
js-mode //
java-mode //
If you don't get this output, I guess you didn't use the code I posted,
or something in your running Emacs changed how it works. As for
changing output-buffer to fundamental-mode at the end, that's just to
restore its initial major-mode, otherwise it would have the major-mode
of the last major mode function evaluated (here, java-mode).
Instead of using comment-start as the let-bound variable, which in your
original code gets overriden by the value of the dynamically scoped
variable comment-start in output-buffer, you could use a variable name
that doesn't get shadowed, e.g. `cmnt-strt', for the let-bound variable.
Then you can keep the use of both the temporary buffer and
output-buffer.
Steve Berman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing comment-start of various modes
2024-08-13 21:55 ` Stephen Berman
@ 2024-08-13 22:10 ` Heime
2024-08-13 22:17 ` Stephen Berman
0 siblings, 1 reply; 7+ messages in thread
From: Heime @ 2024-08-13 22:10 UTC (permalink / raw)
To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor
Sent with Proton Mail secure email.
On Wednesday, August 14th, 2024 at 9:55 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Tue, 13 Aug 2024 21:32:50 +0000 Heime heimeborgia@protonmail.com wrote:
>
> > Sent with Proton Mail secure email.
> >
> > On Wednesday, August 14th, 2024 at 9:13 AM, Stephen Berman
> > stephen.berman@gmx.net wrote:
> >
> > > On Tue, 13 Aug 2024 20:09:57 +0000 Heime heimeborgia@protonmail.com wrote:
> > >
> > > > This function should print the value of comment-start for various modes,
> > > > but I am not getting any comment-start outputs from it.
> > > >
> > > > (defun costart ()
> > > > "Loop through various major modes and print the value of `comment-start`."
> > > >
> > > > (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-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))))))
> > > >
> > > > (switch-to-buffer output-buffer)))
> > >
> > > You successively bind mode-specific value of comment-start in a
> > > temporary buffer, and then switch to output-buffer to print the values,
> > > but this buffer is in fundamental-mode, where comment-start has the
> > > value nil by default. Using the temporary buffer seems superfluous, you
> > > could just use output-buffer:
> > >
> > > (defun costart ()
> > > "Loop through various major modes and print the value of `comment-start`."
> > > (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)))
> > >
> > > Steve Berman
> >
> > What does it matter if the buffer is in fundamental-mode, when I am changing
> > the major mode ? I still do not get the dolist insert for each mode.
>
>
> 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):
>
> 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 <!--
> css-mode /*
> js-mode //
> java-mode //
>
> If you don't get this output, I guess you didn't use the code I posted,
> or something in your running Emacs changed how it works. As for
> changing output-buffer to fundamental-mode at the end, that's just to
> restore its initial major-mode, otherwise it would have the major-mode
> of the last major mode function evaluated (here, java-mode).
>
> Instead of using comment-start as the let-bound variable, which in your
> original code gets overriden by the value of the dynamically scoped
> variable comment-start in output-buffer, you could use a variable name
> that doesn't get shadowed, e.g. `cmnt-strt', for the let-bound variable.
> Then you can keep the use of both the temporary buffer and
> output-buffer.
>
> Steve Berman
Would you have any hints of why one gets this ?
eval-buffer: End of file during parsing: /home/hagbard/Opstk/lumi.el
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing comment-start of various modes
2024-08-13 22:10 ` Heime
@ 2024-08-13 22:17 ` Stephen Berman
2024-08-14 15:59 ` Heime
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2024-08-13 22:17 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
On Tue, 13 Aug 2024 22:10:50 +0000 Heime <heimeborgia@protonmail.com> wrote:
> Would you have any hints of why one gets this ?
>
> eval-buffer: End of file during parsing: /home/hagbard/Opstk/lumi.el
Possibly unbalanced parentheses in the buffer - try `M-x check-parens'.
If that's not the problem, try getting a backtrace, e.g. with `M-x
toggle-debug-on-error' and then evaluating the buffer.
Steve Berman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing comment-start of various modes
2024-08-13 22:17 ` Stephen Berman
@ 2024-08-14 15:59 ` Heime
0 siblings, 0 replies; 7+ messages in thread
From: Heime @ 2024-08-14 15:59 UTC (permalink / raw)
To: Stephen Berman; +Cc: Heime via Users list for the GNU Emacs text editor
Sent with Proton Mail secure email.
On Wednesday, August 14th, 2024 at 10:17 AM, Stephen Berman <stephen.berman@gmx.net> wrote:
> On Tue, 13 Aug 2024 22:10:50 +0000 Heime heimeborgia@protonmail.com wrote:
>
> > Would you have any hints of why one gets this ?
> >
> > eval-buffer: End of file during parsing: /home/hagbard/Opstk/lumi.el
>
>
> Possibly unbalanced parentheses in the buffer - try `M-x check-parens'. If that's not the problem, try getting a backtrace, e.g. with` M-x
> toggle-debug-on-error' and then evaluating the buffer.
>
> Steve Berman
It was the problem, unbalanced parentheses in one of the functions
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-08-14 15:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 20:09 Printing comment-start of various modes Heime
2024-08-13 21:13 ` Stephen Berman
2024-08-13 21:32 ` Heime
2024-08-13 21:55 ` Stephen Berman
2024-08-13 22:10 ` Heime
2024-08-13 22:17 ` Stephen Berman
2024-08-14 15:59 ` Heime
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).