From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hong Xu Newsgroups: gmane.emacs.bugs Subject: bug#74999: [PATCH v2] Recommend `keymap-set' instead of `define-key' in emacs lisp intro Date: Sat, 21 Dec 2024 00:06:53 -0800 Message-ID: <87r0615ujm.fsf@topbug.net> References: <20241220214351.57036-1-hong@topbug.net> <86y1098pvj.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23637"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.12.8; emacs 29.4 Cc: 74999@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 21 09:08:26 2024 Return-path: Envelope-to: geb-bug-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 1tOuXC-00062b-H4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Dec 2024 09:08:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOuWr-0006JW-7J; Sat, 21 Dec 2024 03:08:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOuWp-0006J9-Ad for bug-gnu-emacs@gnu.org; Sat, 21 Dec 2024 03:08:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOuWp-0004fB-2Y for bug-gnu-emacs@gnu.org; Sat, 21 Dec 2024 03:08:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=NR7IjW+/ZGbVg3zzGdSmPRsdHGHLQ2252j/T8VL3fU8=; b=RSc0Qvts9BK7AHSYflmSifbn//wnphqhaBE2Az7ZUQVmi73VeWhORSXysJdgQVCNYpmZtWzOqMQLVcB/V3Q7u9TUJ37E2Te9NfI8JMtuDO+H7Mo/AgRwz57iDdjcCjORSjlllu0DPYlfh7jr5FmJNZD+tU7TaQCdEznE7WDqtJkjYR951Bp4mgg4tR1eBQe6EPridofTuJfTWExaZsNnJzPny/uT99PCliQl1jwMBVXHHtwcBTQPBcHN6GLdoYXG1vIyzt7CMNNBI6JMaEx+3G0AFUOtS6G8uqiCgOl+B3cVwETaBQvo/ByrXubzzhqxxVSuqW1tLOUmkSHh9TyIUw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tOuWo-0003M3-Tq for bug-gnu-emacs@gnu.org; Sat, 21 Dec 2024 03:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Hong Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Dec 2024 08:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74999 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74999-submit@debbugs.gnu.org id=B74999.173476842712785 (code B ref 74999); Sat, 21 Dec 2024 08:08:02 +0000 Original-Received: (at 74999) by debbugs.gnu.org; 21 Dec 2024 08:07:07 +0000 Original-Received: from localhost ([127.0.0.1]:45113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOuVt-0003K7-N1 for submit@debbugs.gnu.org; Sat, 21 Dec 2024 03:07:07 -0500 Original-Received: from sender4-of-o52.zoho.com ([136.143.188.52]:21220) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOuVr-0003Jv-4W for 74999@debbugs.gnu.org; Sat, 21 Dec 2024 03:07:04 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1734768415; cv=none; d=zohomail.com; s=zohoarc; b=daHaC45KMXaaQCtwvImMR8dVMcnq/Qhk1uA6CyPuyD0g1JJai39mSBwYVTwHmcNAGx0kq1iD8Lna7kFRywnwRPMbDmFamQ7dB62CJcqBepU4EufKRupgjJ9ymUgR0Os+UPjtmbX60AOo7/PLItlaNEWQCRvAk1OpdWEsxVmGcQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734768415; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=NR7IjW+/ZGbVg3zzGdSmPRsdHGHLQ2252j/T8VL3fU8=; b=OBWMXEFgTq6rxoKZwD+sRYX9dwiVxjLqub81kLsz3M84Teb9IlNei4PgD3GYno0cAwcMC9IvXrXRkQUA5P8Ltoxm3EWN+4gUp0pTRzehCeGOYOhIJQl2bqVcC0q0OA1Wdpr8Y+Wlct2X7TAnsEkjWeNFN7fS8VCVaBjIdvU01TM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=topbug.net; spf=pass smtp.mailfrom=hong@topbug.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1734768415; s=zoho; d=topbug.net; i=hong@topbug.net; h=From:From:To:To:Cc:Cc:Subject:Subject:In-Reply-To:References:Date:Date:Message-ID:MIME-Version:Content-Type:Message-Id:Reply-To; bh=NR7IjW+/ZGbVg3zzGdSmPRsdHGHLQ2252j/T8VL3fU8=; b=TIo97VeMFob/a+JZT9d/YGvzMFpWOEj4XWIaSBe8D7aWmVgWwiTTQ7H3EImE+l4a Mn6FSZeemw4TolfR36+bvI3rVnNscVLy54RFvvCZFU+XEbdBcqv7U0Cwl4T+SDJC6a4 Sz7ud2TcaInaQHmTM5ep0ElR/RMRnceNRgBcXl1E= Original-Received: by mx.zohomail.com with SMTPS id 1734768413983731.5270865322598; Sat, 21 Dec 2024 00:06:53 -0800 (PST) In-Reply-To: <86y1098pvj.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Dec 2024 09:19:28 +0200") X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:297496 Archived-At: On 2024-12-20 Fri 23:19 GMT-08, Eli Zaretskii wrote: >> From: Hong Xu >> Date: Fri, 20 Dec 2024 13:42:29 -0800 >> >> -Mode-specific keymaps are bound using the @code{define-key} function, >> +Mode-specific keymaps are bound using the @code{keymap-set} function, >> which takes a specific keymap as an argument, as well as the key and >> -the command. For example, my @file{.emacs} file contains the >> -following expression to bind the @code{texinfo-insert-@@group} command >> -to @kbd{C-c C-c g}: >> +the command. For example, the following expression binds the >> +@code{texinfo-insert-@@group} command to @kbd{C-c C-c g}: >> + >> +@smallexample >> +@group >> +(keymap-set texinfo-mode-map "C-c C-c g" 'texinfo-insert-@@group) >> +@end group >> +@end smallexample >> + >> +While you are encouraged to use @code{keymap-set}, you likely would >> +encounter @code{define-key} in various places. @code{define-key} is an >> +older function to create keymaps, and is now considered legacy. > > This should say that historically, Emacs used 'define-key', and > therefore you are likely to see 'define-key' in various places etc. > In addition "older function" is not really accurate: 'keymap-set' > calls 'define-key' internally, so 'define-key' will not disappear from > Emacs any time soon. We just prefer using 'keymap-set' in Lisp > programs because it is higher-level. So instead of saying "older > function", I think we should say "more low-level function". > > Also, please make sure to leave two spaces between sentences, per our > conventions. > >> The >> +above key map can be rewritten in @code{define-key} as: > > Not "key map", but "key binding". The example doesn't show a complete > key map, it only shows a single binding within a key map. Since this > is an introductory manual, we must be very accurate and clear in our > text, to avoid confusing newcomers to Lisp, who are probably confused > already to begin with... > I agree, please see my follow-up patch. -- Thanks, Hong