From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/10569 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.gnus.user Subject: Re: Cursoring in an article : want to add a hook. Date: Tue, 04 Mar 2008 17:49:46 +0100 Message-ID: <87d4qao2mt.fsf@member.fsf.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204649439 9993 80.91.229.12 (4 Mar 2008 16:50:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Mar 2008 16:50:39 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Tue Mar 04 17:51:05 2008 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JWaM0-0006SY-CR for gegu-info-gnus-english@m.gmane.org; Tue, 04 Mar 2008 17:51:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWaLT-0007I6-E7 for gegu-info-gnus-english@m.gmane.org; Tue, 04 Mar 2008 11:50:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JWaL8-00079F-TL for info-gnus-english@gnu.org; Tue, 04 Mar 2008 11:50:07 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JWaL8-00078a-40 for info-gnus-english@gnu.org; Tue, 04 Mar 2008 11:50:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWaL7-00078T-Of for info-gnus-english@gnu.org; Tue, 04 Mar 2008 11:50:05 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JWaL7-0000Jj-3B for info-gnus-english@gnu.org; Tue, 04 Mar 2008 11:50:05 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JWaL1-0008NB-90 for info-gnus-english@gnu.org; Tue, 04 Mar 2008 16:49:59 +0000 Original-Received: from dslb-084-063-036-179.pools.arcor-ip.net ([84.63.36.179]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Mar 2008 16:49:59 +0000 Original-Received: from tassilo by dslb-084-063-036-179.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Mar 2008 16:49:59 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-084-063-036-179.pools.arcor-ip.net User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:E3j9unmc0RK2u/h1KbgOQ2xe+Fw= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.5 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: , Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:10569 Archived-At: Richard G Riley writes: Hi Richard, > Works well. I'd already done this last night actually but used > setq. Is this bad? Not really. You will get compiler warnings when trying to byte-compile it and it's not a clean style. | (defun rdictcc-rgr-translate() | (interactive) | ; (save-window-excursion | (message "myt") | (save-selected-window | (let ((word (rdictcc-current-word))) | (when (and word rdictcc-rgr-show-translations (not(eq word rdictcc-rgr-last-word))) | (rdictcc-translate-word word) | ) | (setq rdictcc-rgr-last-word word) | ) | ) | ) I've "corrected" it to this: --8<---------------cut here---------------start------------->8--- (defun rdictcc-rgr-translate() (interactive) (save-selected-window (let ((word (rdictcc-current-word))) (when (and word rdictcc-rgr-show-translations (not (string= word rdictcc-rgr-last-word))) (rdictcc-translate-word word) (setq rdictcc-rgr-last-word word))))) --8<---------------cut here---------------end--------------->8--- When comparing strings you normally use `string=', because two strings may have the same contents but are not `eq', e.g. they're not the same lisp object. And I've moved the last setq into the `when', cause if the word didn't change there's no reason to re-set it. Bye, Tassilo -- Chuck Norris doesn't see dead people. He makes people dead.