From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: stardiviner Newsgroups: gmane.emacs.help Subject: [SOLVED] Re: Need help on writing an Emacs extension to help reading text content with timer Date: Thu, 30 Jan 2020 14:25:12 +0800 Message-ID: <87sgjx5ulz.fsf@gmail.com> References: <87v9ou5lyq.fsf@gmail.com> <87ftfy9s8z.fsf@gmx.net> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="1776"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.3.2; emacs 27.0.50 Cc: Emacs Help To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 30 07:25:43 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ix3Gp-0000Ox-93 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 30 Jan 2020 07:25:43 +0100 Original-Received: from localhost ([::1]:56300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ix3Go-0002kQ-Ap for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 30 Jan 2020 01:25:42 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53035) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ix3GP-0002kK-O8 for help-gnu-emacs@gnu.org; Thu, 30 Jan 2020 01:25:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ix3GO-0001Gr-Mv for help-gnu-emacs@gnu.org; Thu, 30 Jan 2020 01:25:17 -0500 Original-Received: from [183.246.143.250] (port=8771 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ix3GO-0001Fq-5i for help-gnu-emacs@gnu.org; Thu, 30 Jan 2020 01:25:16 -0500 Original-Received: by dark.localdomain (Postfix, from userid 1000) id 2E933200D4D; Thu, 30 Jan 2020 14:25:13 +0800 (CST) In-reply-to: <87ftfy9s8z.fsf@gmx.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 183.246.143.250 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122318 Archived-At: Stephen Berman writes: > On Wed, 29 Jan 2020 23:19:41 +0800 stardiviner wrote: > > [...] >> (defun amread-start () >> "Start / resume amread." >> (interactive) >> (setq qamread--running > ^ > |:-) > >> (run-with-timer 0 (/ 1.0 amread-wps) #'amread--update))) >> >> (defun amread-stop () >> "Stop amread." >> (interactive) >> (prog1 amread--running >> (when amread--running >> (cancel-timer amread--running) >> (setq amread--running nil) >> (delete-overlay amread--overlay)))) >> >> (defvar amread-mode-map >> (let ((map (make-sparse-keymap))) >> (define-key map (kbd "q") 'amread-stop) >> (define-key map [remap keyaobrd-quit] 'amread-stop) >> map) >> "Keymap for amread-mode buffers.") >> >> (define-minor-mode amread-mode >> "I'm reading qmode." >> :init nil >> :keymap amread-mode-map >> (if amread--running >> (amread-stop) >> (amread-start))) >> #+end_src >> >> But the problem is that I can't stop this timer with defined keybinding =[q]= nor >> with minor mode toggle command =amread-mode=. >> >> I don't know where is the problem. can someone help me to review my code? > > See above. :-) > > Steve Berman Aha, right. I guess this bug is introduced when I write code and testing. Accidentally press =[q]= for testing quit timer. Now it works. Thanks Steve. -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3