From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Flyspell sans flyspell Date: Fri, 15 Jun 2018 16:13:41 +0100 Message-ID: <87po0sozfe.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1529076214 27959 195.159.176.226 (15 Jun 2018 15:23:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2018 15:23:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 15 17:23:30 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fTqZU-0007Ar-Na for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2018 17:23:28 +0200 Original-Received: from localhost ([::1]:47524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTqbb-0003PA-SY for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2018 11:25:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTqQJ-0002Y1-1R for emacs-devel@gnu.org; Fri, 15 Jun 2018 11:14:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTqQF-00086g-TK for emacs-devel@gnu.org; Fri, 15 Jun 2018 11:13:58 -0400 Original-Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:50787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTqQF-000866-Ha for emacs-devel@gnu.org; Fri, 15 Jun 2018 11:13:55 -0400 Original-Received: by mail-wm0-x231.google.com with SMTP id e16-v6so4116777wmd.0 for ; Fri, 15 Jun 2018 08:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version; bh=AkM0hG9KEKNQL7B4J2fFvO3XAaQWcUSm7Y47+bPGGBc=; b=W71lj0BmzwYq8s7yvILj5xBM/lB2XfjbJWDRn3Z7jGvy79xCRgJ88DRXOIWMEkKGeZ MdgliDQ30P6tV8wERXH3aMt9pjG9l8OZ0+VyZBDdOXpaypkOvJmlqYFe4jaWLUd0SEae DRoF/LyghoDeMVaHCw71UNz8ONxOz8YJXxrEvQU4/MNkYarU2vMCEXDbJ2ZZi6m3Yk/D mkXeAKXUSvMrMEaIDiiyeWkvBOHketM/LwFYDI0vVOCccGlPSrLrrwrcmqixZWk7WaiG L4hVZ7VCeyyCPl8Wkp9gYRzWfDbox0oF6LDiiNwCL9auuoh4YDqXj+/shrw9dJ9KsxL9 iKRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=AkM0hG9KEKNQL7B4J2fFvO3XAaQWcUSm7Y47+bPGGBc=; b=MlMzLc3O0QdNUpb74qv8mOW3SXcbNRzKZb6BlZWCrWZyrc7SKmzqaU4CEpudwHfPwh DcJX3hNmjburrQ//xq78SM0uxvaw4aqU1qoTs7tbVAFPs5JigfP9EAFD7lq0WSWxPf1B Kd9WPm94PNYUTujaM8+kd5gfRovkq0g8cMaX8ydRqigMdM0piAWAK/LbFjZ0VEgLQ4+a lqXPP0uabfYpAxTgXS1s9JnZ7aCSvggCHPeQuqsw6E+vAYc0TrIc+nXWC0OVc3Fe4XYV bW4rKeVkoA5yH552ACucF/iD3esqhn93EZrliG5kQ2EesaWpmq0xtPFIxCNfrlYdzU90 blJQ== X-Gm-Message-State: APt69E1Foh8v8abX5I2rSBvcbDfB7dVX3lHHMRr8QQAbeCjHldGbYlq/ RGYqIqV+ujv75a2V9qWooeoUqejG X-Google-Smtp-Source: ADUXVKIlflj6Q5xNtKEGhLQ2yBtaBxiS30AnnyKd9qx7mVTx/WeOEV07qHz78n+oraBo+yGBY6OwBA== X-Received: by 2002:a1c:a8a:: with SMTP id 132-v6mr1662822wmk.44.1529075633984; Fri, 15 Jun 2018 08:13:53 -0700 (PDT) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id p196-v6sm2951695wmb.20.2018.06.15.08.13.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 08:13:52 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226331 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Or rather, avec du Flymake. I just pushed some updates that allow Flymake and backends to exchange hints about the modified portions of the buffer. This in turn allowed me to build a very simple prototype flyspell-flymake.el (attached after the sig) with backends that reuse Flyspell's machinery and turn Flymake into a spell checker. It is not really usable since it suffers a lot from Flyspell's quirks like moving the point as it's checking words, a lot of chatter in the echo area, and probably more that I haven't noticed. This is mainly because Flyspell doesn't provide any kind of API, and all I did was override the overlay API around calls to `flyspell-region' using `cl-letf. Still, works better than I expected it to. If you want to try it, build a recent master, load the attached file, and eval one of the following (add-hook 'flymake-diagnostic-functions 'flyspell-prog-flymake) ; for pr= ogramming (add-hook 'flymake-diagnostic-functions 'flyspell-flymake) ; for text Then M-x flymake-mode Jo=C3=A3o --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=flyspell-flymake.el Content-Transfer-Encoding: quoted-printable ;;; flyspell-flymake.el --- Flymake backend for flyspell, i.e. flyspell san= s flyspell -*- lexical-binding: t; -*- ;; Copyright (C) 2018 Free Software Foundation, Inc. ;; Author: Jo=C3=A3o T=C3=A1vora ;; Keywords: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; ;;; Code: (require 'cl-lib) (require 'flyspell) (require 'flymake) (defun flyspell--sans-flyspell-region (&optional beg end) "Fake-flyspell region between BEG and END. Intead of making overlays, return Flymake diagnostics" (let (diags) (cl-letf (((symbol-function 'overlays-in) (lambda (beg end) (cl-remove-if-not (lambda (diag) (let ((diag-beg (flymake-diagnostic-beg diag)) (diag-end (flymake-diagnostic-end diag))) (and (< diag-beg end) (> diag-end beg)))) diags))) ((symbol-function 'make-overlay) (lambda (beg end &optional buffer &rest ignored) (let ((diag (flymake-make-diagnostic (or buffer (current-buffer)) beg end 'flyspell-flymake-mispelling "I thing you misspelled this."))) (push diag diags) diag))) ((symbol-function 'delete-overlay) (lambda (diag) (setq diags (delq diag diags)))) ((symbol-function 'overlayp) (lambda (thing) (flymake--diag-p thing))) ((symbol-function 'overlay-put) (lambda (diag prop value) (setf ( flymake--diag-data diag) (plist-put (flymake-diagnostic-data di= ag) prop value)))) ((symbol-function 'overlay-get) (lambda (diag prop) (plist-get (flymake-diagnostic-data diag) prop))) ((symbol-function 'overlay-properties) #'flymake-diagnostic-d= ata)) (save-excursion (if (and beg end) (flyspell-region beg end) (flyspell-region (point-min) (point-max))))) diags)) (put 'flyspell-flymake-mispelling 'flymake-severity (warning-numeric-level = :warning)) (put 'flyspell-flymake-mispelling 'flymake-category :note) (put 'flyspell-flymake-mispelling 'flymake-overlay-control `((mouse-face . highlight) (keymap . ,(let ((map (make-sparse-keymap))) (define-key map [mouse-2] 'flyspell-correct-word) map)))) ;;;###autoload (cl-defun flyspell-flymake (report-fn &key changes-start changes-end &allow-other-keys) (let ((diagnostics (flyspell--sans-flyspell-region changes-start changes-= end))) (apply report-fn diagnostics (if (and changes-start changes-end) (list :region (cons changes-start changes-end)))) diagnostics)) ;;;###autoload (cl-defun flyspell-prog-flymake (report-fn &rest args) (let* ((flyspell-generic-check-word-predicate #'flyspell-generic-progmode= -verify)) (apply #'flyspell-flymake report-fn args))) (provide 'flyspell-flymake) ;;; flyspell-flymake.el ends here --=-=-=--