all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Finding and fixing the missing brackets for tcl script with Emacs.
@ 2021-01-14 10:30 Hongyi Zhao
  2021-01-14 11:22 ` tomas
  0 siblings, 1 reply; 3+ messages in thread
From: Hongyi Zhao @ 2021-01-14 10:30 UTC (permalink / raw)
  To: help-gnu-emacs

See the following TCL script snippet:

---
set sendcmds [lmap l [split [string trim $sendcmds] \n] {
if {[regexp {^\s*#} $l} continue
string trim $l
}]
---

In the above code snippets, two close brackets are missed. But finding
and fixing this sort of error manually is indeed a tedious and
laborious job. Can Emacs help me find the right spot and fix the
problem quickly for this scenario?

Best,
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Finding and fixing the missing brackets for tcl script with Emacs.
  2021-01-14 10:30 Finding and fixing the missing brackets for tcl script with Emacs Hongyi Zhao
@ 2021-01-14 11:22 ` tomas
  2021-01-14 13:34   ` Hongyi Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: tomas @ 2021-01-14 11:22 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

On Thu, Jan 14, 2021 at 06:30:20PM +0800, Hongyi Zhao wrote:
> See the following TCL script snippet:
> 
> ---
> set sendcmds [lmap l [split [string trim $sendcmds] \n] {
> if {[regexp {^\s*#} $l} continue
> string trim $l
> }]
> ---
> 
> In the above code snippets, two close brackets are missed. But finding
> and fixing this sort of error manually is indeed a tedious and
> laborious job. Can Emacs help me find the right spot and fix the
> problem quickly for this scenario?

I'm assuming you use Tcl mode.

I don't know what kind of help you expect. There are several
possibilities. Among them, I use paren minor mode (enable it
with M-x "show-paren-mode"), which highlights matching parens
and shows you another colour when there is a mismatch.

This can't be perfect, especially in a language like Tcl (I
don't know whether paren-mode "sees through comments", as
the Tcl parser does -- an uncommon choice :)

There is a whole section in the Emacs manual dedicated to
this:

  "26.4.3 Matching Parentheses"

or, on the Internet

  https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Finding and fixing the missing brackets for tcl script with Emacs.
  2021-01-14 11:22 ` tomas
@ 2021-01-14 13:34   ` Hongyi Zhao
  0 siblings, 0 replies; 3+ messages in thread
From: Hongyi Zhao @ 2021-01-14 13:34 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

On Thu, Jan 14, 2021 at 7:22 PM <tomas@tuxteam.de> wrote:
>
> On Thu, Jan 14, 2021 at 06:30:20PM +0800, Hongyi Zhao wrote:
> > See the following TCL script snippet:
> >
> > ---
> > set sendcmds [lmap l [split [string trim $sendcmds] \n] {
> > if {[regexp {^\s*#} $l} continue
> > string trim $l
> > }]
> > ---
> >
> > In the above code snippets, two close brackets are missed. But finding
> > and fixing this sort of error manually is indeed a tedious and
> > laborious job. Can Emacs help me find the right spot and fix the
> > problem quickly for this scenario?
>
> I'm assuming you use Tcl mode.
>
> I don't know what kind of help you expect. There are several
> possibilities. Among them, I use paren minor mode (enable it
> with M-x "show-paren-mode"), which highlights matching parens
> and shows you another colour when there is a mismatch.
>
> This can't be perfect, especially in a language like Tcl (I
> don't know whether paren-mode "sees through comments", as
> the Tcl parser does -- an uncommon choice :)
>
> There is a whole section in the Emacs manual dedicated to
> this:
>
>   "26.4.3 Matching Parentheses"
>
> or, on the Internet
>
>   https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html

Thanks a lot for your information. I find another more powerful
package which seems to be dedicated to this kind of work, see
<https://github.com/Fuco1/smartparens> for more detailed info. I'll
give it a try.

Best
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Polytechnic University of Science and Technology engineering
NO. 552 North Gangtie Road, Xingtai, China



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-14 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-14 10:30 Finding and fixing the missing brackets for tcl script with Emacs Hongyi Zhao
2021-01-14 11:22 ` tomas
2021-01-14 13:34   ` Hongyi Zhao

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.