From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: The convenient method to check/inspect/retrieve the definition/usage of any commands/symbols/operators used in elisp code. Date: Wed, 23 Jun 2021 16:56:47 +0800 Message-ID: References: <87sg1dgbbk.fsf@omarpolo.com> <87pmwhg843.fsf@omarpolo.com> <8735t96mxj.fsf@omarpolo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30591"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Omar Polo Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 23 10:59:19 2021 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 1lvyj9-0007oL-7T for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 23 Jun 2021 10:59:19 +0200 Original-Received: from localhost ([::1]:46482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvyj8-0004pi-7h for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 23 Jun 2021 04:59:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvygx-0002Eg-Ok for help-gnu-emacs@gnu.org; Wed, 23 Jun 2021 04:57:03 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:41781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvygv-0004yT-Hl for help-gnu-emacs@gnu.org; Wed, 23 Jun 2021 04:57:03 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id z22so1948920ljh.8 for ; Wed, 23 Jun 2021 01:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=aL0wNXEFDa4JqDQW0BaGYbpj1nExl+It5++Hw4pNMMI=; b=LU0enlJg4d2d2YrZuTtbpbeB6cINXNRhaWiyS7EaPe3enidDdluoCkmBHwAc1ZghP6 JoiTesZopZK1g9r59ApXOQ4Bu9R5UJpKIW/WOKIlHighpeiwcxstUYRc+H2uvdxX148y Z6fSuZeFqfViTaep/3WhO+szmrML6leASbIedzlbPxeXFiRU3B+n3w6PkAB88aXrI3Fw 8PzZKM2q5ZhkWLSL63q3HVouhCV12NLFdNMAHL09HuKuQqoCNkVB8XOIKMBw9yQH2jJi eANc21CEgyboH0NY/FYhlpttIoUR8RQzBSfMT1ZsLGzWFYWr8AQlkIL/D4G0kfWrKMPn y9EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=aL0wNXEFDa4JqDQW0BaGYbpj1nExl+It5++Hw4pNMMI=; b=nldfxBNcOwygtk/NAe8KU60gB8TAWn7H8zLJ2TmZT7Dz7eYfudD0V8EfL80s1IiYpB ZpSLL/s33HA56cxukGKVoUPJWxMXE+oATOB/2BenFqrR90hGvnt6C+lG9NdnMHXBtwJV iAHvyQ0TFVvRbghfO9jERkx1F4bL73LLlcAzRKqnjvaxsa7zOuB4/SnBI23Rc8RbHKkz BePHqu/59O6XounPmWQMSQCeUZFET2CY5DEL0VqIqhYdGbZQBahrPcqyTfFSkji5ml0c mFH3UToAqWX+xoBf2z1S5eeknOGSsRI1/cQeYNEzr4Ldr+wzx4IuLBT2PtDfPzJeEZeu 24UA== X-Gm-Message-State: AOAM5315uVs+gYDfgyKPvU66diFcwaycKky9j2/mZB5OP+n7SXlKuUza OuxuYciG4ODbOc/pkFK/aDkJiLMrIhPEHFfgads= X-Google-Smtp-Source: ABdhPJwr7ZO8L1rTiBuekSWEkfdakYTnISpMroMHy1AS09Qv82BgfADynkTu2gG7a2F/kNmwQJ3Q22BK7OFt8sXOqHc= X-Received: by 2002:a2e:9652:: with SMTP id z18mr2013696ljh.413.1624438619712; Wed, 23 Jun 2021 01:56:59 -0700 (PDT) In-Reply-To: <8735t96mxj.fsf@omarpolo.com> Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:131209 Archived-At: On Wed, Jun 23, 2021 at 3:49 PM Omar Polo wrote: > > (sorry for the delay) > > Hongyi Zhao writes: > > > On Sat, Jun 19, 2021 at 11:57 PM Omar Polo wrote: > >> > >> > >> Hongyi Zhao writes: > >> > >> > On Sat, Jun 19, 2021 at 10:48 PM Omar Polo wrote: > >> >> > >> >> > >> >> Hongyi Zhao writes: > >> >> > >> >> > Dear all, > >> >> > > >> >> > Are there any built-in method of Emacs which can let me convenien= tly > >> >> > check/inspect/retrieve the definition/usage of any > >> >> > commands/symbols/operators used in elisp code at-the-point/in-sit= u? > >> >> > Say, for the following code snippets: > >> >> > > >> >> > ;;; > >> >> > (defun fk/company-wordfreq-toggle-language (&optional language) > >> >> > (interactive) > >> >> > (setq ispell-local-dictionary (or language > >> >> > (if (string=3D > >> >> > ispell-local-dictionary "english") > >> >> > "turkish" > >> >> > "english"))) > >> >> > [...] > >> >> > `(progn > >> >> > ,@(mapcar (lambda (p) `(use-package ,p)) > >> >> > packages))) > >> >> > > >> >> > (use-multiple-packages flycheck > >> >> > dash > >> >> > ) > >> >> > > >> >> > [...] > >> >> > (mapcar #'straight-use-package '(flycheck lsp-mode dash ...)) > >> >> > > >> >> > ;or equivalently > >> >> > > >> >> > (defvar my-package-list '(flycheck lsp-mode dash ...)) > >> >> > (mapcar #'straight-use-package my-package-list) > >> >> > ;;; > >> >> > > >> >> > I want to find some convenient methods built in Emacs itself with= an > >> >> > in-situ manner - by moving the point to the interest position - t= o > >> >> > check any commands/symbols/operators used in them. > >> >> > > >> >> > Regards > >> >> > >> >> there is M-. (xref-find-definitions) that will jump to the definiti= on of > >> >> the symbol at point (at least in emacs lisp buffers), > >> > > >> > Thank you very much. But still there are some symbols can't find wit= h > >> > this method, say, #' ,@ ' and so on. > >> > >> #' ' ` , and ,@ aren't symbols, they are reader macros, i.e. special > >> character sequences that the lisp reader expands into some special > >> constructs. For instance, #'foo is the same as (function 'foo) and 'f= oo > >> the same as (quote foo). > >> > >> If you M-. with the point over quote (in an elisp buffer) it should ju= mp > >> to eval.c (assuming you have the C source files available). > >> > >> >> and M-, (xref-pop-marker-stack) to jump back. > >> > > >> > I use scratch buffer to test, and it can't jump back there. > >> > >> M-, is meant to be used after one or more M-. > >> > >> For instance: > >> > >> 1. in *scratch* type describe-function > >> 2. press M-. -- it'll jump to help-fns.el.gz > >> 3. move the point over with-help-window (something like ~10 lines belo= w) > >> 4. M-. again -- it'll jump to a different place in the same file > >> 5. go back with M-, -- now you're back in the definition of > >> describe-function > >> 6. M-, again -- now you're back in the *scratch* buffer > > > > Wonderful explanations. But I still failed to reproduce the M-, , as > > for the other steps you told above except the last two, I can > > reproduce them exactly the same as you described. > > > > See the attachment for the info I saw on the bottom mini-buffer when > > hitting M-, (M- comma). > > don't want to sound rude, but could you please refrain from attaching a > whole screenshot just for an error message? Copying the error, like: > > "it says that: buffer is read-only" > > it's enough IMHO. (you'll find a copy of the error message in the > *Messages* buffer if you don't want to type it by hand.) > > Now, usually that error is signaled when you try to insert something > into a buffer that read-only. There can be multiple reasons for that, > but unfortunately I thinks it's something on your end, since I cannot > reproduce with `emacs -Q'. Make sure that you are hitting M-, and not > the comma alone, or ensure that M-, is bound to xref-pop-marker-stack > and not to something else (C-h k M-,) Thank you very much. Because of my negligence, the real input sequence I've tried before is as follows: (C-h k M-') > > As en extreme solution, try to enable the debug-on-error (M-x > toggle-debug-on-error RET) and look at the stacktrace when that error > happens. (You can use toggle-debug-on-error again to disable it later) > > >> > >> >> > >> >> Or you can C-h f or C-h v (describe-function/variable) and then M-n > >> >> (next-history-element) to bring in the symbol at point. > >> > > >> > I meet the following message: M-n is undefined, as shown in the > >> > attached screenshot file. > >> > >> M-n should be defined in some minibuffer maps; with `emacs -Q' I can > >> > >> C-h v C-h k M-n > >> > >> and it tells me that. > > > > I got the following with your above command sequence: > > > > M-n runs the command next-history-element (found in > > minibuffer-local-must-match-map), which is an interactive compiled > > Lisp function in =E2=80=98simple.el=E2=80=99. > > > > It is bound to , , M-n, > > . > > > > (next-history-element N) > > > > Puts next element of the minibuffer history in the minibuffer. > > With argument N, it uses the Nth following element. The position > > in the history can go beyond the current position and invoke "future > > history." > > Yep. Sorry for giving a long command sequence without any explanation. > `C-h v' is describe-variable, it should enter the minibuffer asking for > a variable to be described. Then `C-h k' is describe-key, that works in > the minibuffer too. M-n is bound to next-history-element there too, so > it should work. When you are over (or at the beginning) of a symbol, > M-n should pull that symbol into the minibuffer. So with the cursor > over > > toggle-debug-on-error > > if I type `C-h f' (describe-function) and then M-n, Emacs automatically > inserts "toggle-debug-on-error" as input in the minibuffer. Then I can > simply RET to read the documentation of the function :) Wonderful. Got it. Thank you very much again. HY > > > HY > > > >> > >> > M-n runs the command next-history-element (found in > >> > minibuffer-local-must-match-map), which is an interactive compiled > >> > Lisp function in =E2=80=98simple.el=E2=80=99. > >> > >> Cheers, > >> > >> > HY > >> > --=20 Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering NO. 552 North Gangtie Road, Xingtai, China