From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/18123 Path: news.gmane.org!not-for-mail From: Pietro Newsgroups: gmane.emacs.gnus.user Subject: Re: Trigger spell checking before sending Date: Thu, 18 Feb 2016 10:11:23 -0600 Message-ID: <877fi2dmms.fsf@pietrop-debian64RfL.eng.citrite.net> References: <874mde27a9.fsf@posteo.net> <874mdeddos.fsf@debian.uxu> <87vb5uvxbd.fsf@pietrop-debian64RfL.eng.citrite.net> <87mvr5ql03.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1455812086 3160 80.91.229.3 (18 Feb 2016 16:14:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Feb 2016 16:14:46 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Thu Feb 18 17:14:39 2016 Return-path: Envelope-to: gegu-info-gnus-english@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 1aWRDy-0005rp-Su for gegu-info-gnus-english@m.gmane.org; Thu, 18 Feb 2016 17:14:39 +0100 Original-Received: from localhost ([::1]:42762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWRDy-00024Q-6K for gegu-info-gnus-english@m.gmane.org; Thu, 18 Feb 2016 11:14:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWRDu-00024J-Mn for info-gnus-english@gnu.org; Thu, 18 Feb 2016 11:14:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWRDr-0003Kj-Fu for info-gnus-english@gnu.org; Thu, 18 Feb 2016 11:14:34 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:43814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWRDr-0003K1-8i for info-gnus-english@gnu.org; Thu, 18 Feb 2016 11:14:31 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aWRDo-0005kG-T8 for info-gnus-english@gnu.org; Thu, 18 Feb 2016 17:14:29 +0100 Original-Received: from 185.25.64.249 ([185.25.64.249]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Feb 2016 17:14:28 +0100 Original-Received: from pulsarpietro by 185.25.64.249 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Feb 2016 17:14:28 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 185.25.64.249 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:QhizEpLNLQlBCbs1s/PlaeNRk3E= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:18123 Archived-At: Emanuel Berg writes: > Pietro writes: > >> Alternatively I am thinking of writing a function >> which asks the user for the language the ispell >> function should check for, it does not need to >> accept all the languages and for instance I would be >> more than happy to have something like that : >> >> Mini-buffer says: [Which language ?[e : English, i: >> Italian] > > I still don't like the idea of having this complicated > a thing in a hook; on the other hand, I just realized > that the code I provided isn't compatible with the > hook solution, so it isn't of any help if you are set > on that idea. > > OK, try this, only change the Swedish stuff for > Italian, no? > > (defun message-spell-before-send (lang-char) > (interactive "s(e)nglish or (s)wedish: ") > (let ((lang (pcase lang-char > ("e" "american-insane") ; these has to be added outside of Emacs > ("s" "svenska") ))) > (if lang > (progn > (ispell-change-dictionary lang) ; N.B. side-effect - this isn't reset > (ispell-message) ) > (message "Spelling not done - no support for: %s" lang-char) ))) > > If you don't want to spell, just hit RET. Hi, sorry for my late reply, I was busy ... working! Ouch! Thanks a lot for your answers guys, much appreciated :-) I would like to implement one of the previous follow up which explained how to auto detect the buffer's language but for now I would be more than happy with this simple and good solution, the function works fine when I call it from M-x "name-function" but something strange happens when that is called by the message-send hook: run-hooks: Wrong number of arguments: (lambda (lang-char) (interactive "s(e)nglish or (s)wedish: ") (let ((lang (cond ((equal lang-char "e") (let nil "british")) ((equal lang-char "i") (let nil "italiano")) (t nil)))) (if lang (progn (ispell-change-dictionary lang) (ispell-message)) (message "Spelling not done - no support for: %s" lang-char)))), 0 This is what I get in my mini-buffer when I send my email, any thoughts ? I am new to Emacs Lisp therefore I could some silly mistake. Thanks a lot. Pietro