From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.devel Subject: [PATCH] Custom option to turn Flyspell mode on in prog modes Date: Mon, 09 Dec 2013 01:25:08 +0100 Message-ID: <87ppp6vpjv.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1386548713 25141 80.91.229.3 (9 Dec 2013 00:25:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Dec 2013 00:25:13 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 09 01:25:19 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vpoez-0008TT-JI for ged-emacs-devel@m.gmane.org; Mon, 09 Dec 2013 01:25:17 +0100 Original-Received: from localhost ([::1]:41321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vpoey-0003z5-Hd for ged-emacs-devel@m.gmane.org; Sun, 08 Dec 2013 19:25:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vpoeu-0003z0-Le for emacs-devel@gnu.org; Sun, 08 Dec 2013 19:25:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vpoet-0000B7-Kx for emacs-devel@gnu.org; Sun, 08 Dec 2013 19:25:12 -0500 Original-Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:62657) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vpoet-0000Az-EE for emacs-devel@gnu.org; Sun, 08 Dec 2013 19:25:11 -0500 Original-Received: by mail-wg0-f47.google.com with SMTP id n12so2698889wgh.2 for ; Sun, 08 Dec 2013 16:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=pQDIVV6TyC0VQ2C9gpUbWHy1mBwfh07fyaraaCkCTag=; b=JjmnNljLeFIbvbahSbzZLSrMJb1tFTuUfSsFcGLL09YRJ/ZkCTtUnLAa4Z/XCHNkaa OzMZU1mD46LJKo9CnNJyH4hZdUdV+YdddJKYHXdSgNtq9cepE0hi02tgVbgrN+PYfeMh kd7+m8yUP8VXtDuqRw+NjRxIzJSM/JTlK8wLdhAO0T09YiVJX0TRLXbhKnuk5+2yJ/49 /HfCChKWBPmM1XN5rLINYrEX4D5Q+fazkPMbC7giO3p5z03SfXJn+2MDQuLKpIujz/7P 5DCVFoVpX8dTEWX4oXp+S8BudaHwWaJLmP+eGHUiS/tiZ66dSnyzVRg/sAGO5HEJvu5Z +sjw== X-Received: by 10.180.189.68 with SMTP id gg4mr11694502wic.46.1386548710466; Sun, 08 Dec 2013 16:25:10 -0800 (PST) Original-Received: from choubidou.localdomain ([2a01:e35:2ef1:4540:290:f5ff:feb9:5d26]) by mx.google.com with ESMTPSA id fu1sm19763754wib.8.2013.12.08.16.25.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 16:25:09 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::22f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:166224 Archived-At: --=-=-= Content-Type: text/plain; format=flowed The attached patch allows users to enable spell checking in prog modes by customization means. Thanks to `flyspell-prog-mode', the spell checking is done in comments and strings only. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Custom-option-to-turn-Flyspell-mode-on-in-prog-modes.patch >From 0898bacd9012a0d01da417b3f491f008d4bdefe8 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Mon, 9 Dec 2013 01:20:11 +0100 Subject: [PATCH] Custom option to turn Flyspell mode on in prog modes --- lisp/progmodes/prog-mode.el | 6 ++++++ lisp/textmodes/flyspell.el | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index b3ed328..92820dc 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -35,6 +35,12 @@ "Generic programming mode, from which others derive." :group 'languages) +(defcustom prog-mode-hook nil + "Normal hook run when entering Text mode and many related modes." + :type 'hook + :options '(turn-on-flyspell-prog) + :group 'prog-mode) + (defvar prog-mode-map (let ((map (make-sparse-keymap))) (define-key map [?\C-\M-q] 'prog-indent-sexp) diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 81f17c8..0ce0a90 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -519,11 +519,17 @@ in your init file. (flyspell-mode 1)) ;;;###autoload +(defun turn-on-flyspell-prog () + "Unconditionally turn on Flyspell mode for comments and strings." + (flyspell-prog-mode)) + +;;;###autoload (defun turn-off-flyspell () "Unconditionally turn off Flyspell mode." (flyspell-mode -1)) (custom-add-option 'text-mode-hook 'turn-on-flyspell) +(custom-add-option 'prog-mode-hook 'turn-on-flyspell-prog) ;;*---------------------------------------------------------------------*/ ;;* flyspell-buffers ... */ -- 1.8.5.1 --=-=-= Content-Type: text/plain; format=flowed -- Matthias --=-=-=--