From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Newsgroups: gmane.emacs.bugs Subject: bug#6411: Ispell string or comment, bug#6411: Ispell string or comment Date: Wed, 08 Apr 2020 21:23:20 +0200 Message-ID: <87k12pkcif.fsf@gmail.com> References: <83r25ejvjm.fsf@gnu.org> <83r25ejvjm.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="60441"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Kangas , lennart.borgman@gmail.com, 6411@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 08 21:29:20 2020 Return-path: Envelope-to: geb-bug-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 1jMGO0-000Fcv-6B for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Apr 2020 21:29:20 +0200 Original-Received: from localhost ([::1]:39872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMGNz-000605-10 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Apr 2020 15:29:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34451) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMGHv-0004t8-46 for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2020 15:23:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMGHt-0002CZ-RF for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2020 15:23:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41373) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMGHt-0002CR-Nn for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2020 15:23:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jMGHt-0006xO-J9 for bug-gnu-emacs@gnu.org; Wed, 08 Apr 2020 15:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Apr 2020 19:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6411 X-GNU-PR-Package: emacs Original-Received: via spool by 6411-submit@debbugs.gnu.org id=B6411.158637378026735 (code B ref 6411); Wed, 08 Apr 2020 19:23:01 +0000 Original-Received: (at 6411) by debbugs.gnu.org; 8 Apr 2020 19:23:00 +0000 Original-Received: from localhost ([127.0.0.1]:52919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jMGHs-0006x9-1m for submit@debbugs.gnu.org; Wed, 08 Apr 2020 15:23:00 -0400 Original-Received: from mail-lj1-f173.google.com ([209.85.208.173]:39684) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jMGHp-0006ww-Jp for 6411@debbugs.gnu.org; Wed, 08 Apr 2020 15:22:58 -0400 Original-Received: by mail-lj1-f173.google.com with SMTP id i20so8897412ljn.6 for <6411@debbugs.gnu.org>; Wed, 08 Apr 2020 12:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=cHJ0vpL81n6ixFue4hLHb+QljVcdhOOxnN0i+bGSSbY=; b=Kjgkohguje0XRaRCmN/wCW6a1MoK5j6ga7404cp+K4Swmxz3fD7Uapr6IUsyyXPA1j IDdLYiQ563hn162y2DQFGQ625H4PFD39kVkdUNacEXBv06W0hAZl613NkNi2LMxNrqWc rXI5MtuCM8/bfJY55dMhA3JEK1AmG6TyJlLxtAdeeWo1nJrnlJ5zNMCMdU2nefcHNbCt p3tUsMLbfd6LyUeva9383Gm/ZIlR+Gnaw8fKY/Ewz/gWlP2oRIldazoWXFT1aGrihDma p4Fh5pSh9QXWj95K/hgpfFTVVkXmBS7wZG/njU+PBgH3F/0hicMphNc8AyN0dfvP3a68 4HAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=cHJ0vpL81n6ixFue4hLHb+QljVcdhOOxnN0i+bGSSbY=; b=gHLv2MvoTS6CufOevxkY7UQ4I70fhrmkMdakdvGxdbTlEVWy9HZPRFF8M2iEpkUPUD wyFTdbn3hxHHuqegymAu4p1OpgjLGcov5GSvRd+e9/UWvdxCydGGzbupIBjWa7V1VeNM O+iAEMWIRSAWLnM+MJhVhcosvIBTDOUwonOzDUP5Xzer/68UbviK3ga/rcwgYt6Bo+Bs 1rmJyXEOYb/uSMEhGioGee24n0OSKmPUjHr5skKZyCc7Ng4Xtv5mL7NWehmfDHoY2B56 3PZcDYvxVbVeL6rKkLbKUfgBlJFn4W1ETRLjbuTdIxHs77P0MAcaQjkb70RyvLMNxNhf MiHA== X-Gm-Message-State: AGi0PuZc9mjGuqmE0QAPlKZXyL1w22o4Cnzg5lYIJ4fuvfnZvicANEK3 2/AQxuFem4/oORjLiE8Vx14= X-Google-Smtp-Source: APiQypItPdLPKNXah8FEzQZj1VjRLER8kFh8ojzdhAHrJGpFMiiCoAoU6bxWXKpsl1pC0SEKJ+W9jg== X-Received: by 2002:a2e:9798:: with SMTP id y24mr6087504lji.267.1586373771330; Wed, 08 Apr 2020 12:22:51 -0700 (PDT) Original-Received: from localhost ([185.112.167.47]) by smtp.gmail.com with ESMTPSA id m17sm14105724ljb.61.2020.04.08.12.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 12:22:48 -0700 (PDT) In-Reply-To: <83r25ejvjm.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 21 Aug 2019 20:08:29 +0300, Wed, 21 Aug 2019 22:57:21 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178149 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 6411 + patch thanks On Wed, 21 Aug 2019 20:08:29 +0300 Eli Zaretskii wrote: > Sorry, but I happen to think the proposed implementation is somewhat > inelegant: > > . what's with the "(interactive (list nil))" part? > . why not just make ispell-comments-and-strings accept a prefix > argument to modify its behavior? > . alternatively, why not make ispell-comments-and-strings be > sensitive to the active region? > . as yet another alternative, make the new ispell-comment-or-string > narrow to the comment/string at point and then call > ispell-comments-and-strings with no code changes whatsoever; then > make the new command be sensitive to active region, and fall back > on the string/comment at point if no active region On Wed, 21 Aug 2019 22:57:21 +0200 Stefan Kangas wrote: > Let's hope someone picks up the ball and provides us with a revised or > new patch. If Lennart Borgman doesn't feel up to it after all these > years, maybe someone else? Here's my take on it. I didn't go the narrowing route, as I think it is useful to have full context during spelling corrections (recursive edit etc.). I also didn't see an obvious way to reuse one function/command from the other, as in order to get bounds of a comment/string, we have to parse the (part of the) buffer, by which point we can just pass the bounds straight to `ispell-region'. I did update `ispell-comments-and-strings' to honour active region and take optional bounds, anyway, as it seems useful in itself. One other possibility I see would be to merge the two commands and condition the "at-point" functionality on a prefix argument, but then the name ('ispell-comments-and-strings') would probably have to be changed, anyway (and to what?), and perhaps the command would already become too much of a kitchen sink. --=20 =C5=A0t=C4=9Bp=C3=A1n --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ispell-Commands-to-check-comments-or-strings-at-poin.patch >From 9ea826c09e848f18b9c09e23c00d525da26d280b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20N=C4=9Bmec?= Date: Wed, 8 Apr 2020 20:32:51 +0200 Subject: [PATCH] ispell: Commands to check comments or strings at point or in region * lisp/textmodes/ispell.el (ispell-comments-and-strings): Accept START and END arguments, defaulting to active region in interactive calls. (ispell-comment-or-string-at-point): New command. (bug#6411) --- etc/NEWS | 7 +++++++ lisp/textmodes/ispell.el | 30 +++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index fa5478679f..f7f18d12b9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -144,6 +144,13 @@ this user option. +++ *** New command 'describe-keymap' describes keybindings in a keymap. +** Ispell +--- +*** 'ispell-comments-and-strings' now accepts START and END arguments, +defaulting to active region when used interactively. +--- +*** New command 'ispell-comment-or-string-at-point' is provided. + --- ** The old non-SMIE indentation of 'sh-mode' has been removed. diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index a9fbd2f04c..e1642a8d87 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -3591,24 +3591,40 @@ ispell-process-line ;;;###autoload -(defun ispell-comments-and-strings () - "Check comments and strings in the current buffer for spelling errors." - (interactive) - (goto-char (point-min)) +(defun ispell-comments-and-strings (&optional start end) + "Check comments and strings in the current buffer for spelling errors. +If called interactively with an active region, check only comments and +strings in the region. +When called from Lisp, START and END buffer positions can be provided +to limit the check." + (interactive (when (use-region-p) (list (region-beginning) (region-end)))) + (unless end (setq end (point-max))) + (goto-char (or start (point-min))) (let (state done) (while (not done) (setq done t) - (setq state (parse-partial-sexp (point) (point-max) - nil nil state 'syntax-table)) + (setq state (parse-partial-sexp (point) end nil nil state 'syntax-table)) (if (or (nth 3 state) (nth 4 state)) (let ((start (point))) - (setq state (parse-partial-sexp start (point-max) + (setq state (parse-partial-sexp start end nil nil state 'syntax-table)) (if (or (nth 3 state) (nth 4 state)) (error "Unterminated string or comment")) (save-excursion (setq done (not (ispell-region start (point)))))))))) +;;;###autoload +(defun ispell-comment-or-string-at-point () + "Check the comment or string containing point for spelling errors." + (interactive) + (save-excursion + (let ((state (syntax-ppss))) + (if (or (nth 3 state) (nth 4 state)) + (ispell-region (nth 8 state) + (progn (parse-partial-sexp (point) (point-max) + nil nil state 'syntax-table) + (point))) + (user-error "Not inside a string or comment"))))) ;;;###autoload (defun ispell-buffer () -- 2.26.0 --=-=-=--