Tassilo Horn <[EMAIL PROTECTED]> writes: > Richard G Riley <[EMAIL PROTECTED]> 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: > > (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))))) > > 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
Thanks. All pointers appreciated. I tend to only pop into elisp when I need something and it rarely sticks into my head since its such a rare occurrence and lisp isn't the most obvious language from coming from C :-; _______________________________________________ info-gnus-english mailing list [email protected] http://lists.gnu.org/mailman/listinfo/info-gnus-english
