From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Is there way to read function invoked and its parameters? Date: Mon, 28 Dec 2020 02:11:12 +0700 Message-ID: References: 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="34603"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help GNU Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 27 20:11:51 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 1ktbSJ-0008vb-Jl for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 20:11:51 +0100 Original-Received: from localhost ([::1]:38480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktbSI-0003jl-MF for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 14:11:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktbRv-0003hE-88 for help-gnu-emacs@gnu.org; Sun, 27 Dec 2020 14:11:27 -0500 Original-Received: from mail-vs1-xe2e.google.com ([2607:f8b0:4864:20::e2e]:38424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktbRt-0002TR-EG for help-gnu-emacs@gnu.org; Sun, 27 Dec 2020 14:11:26 -0500 Original-Received: by mail-vs1-xe2e.google.com with SMTP id z16so4634276vsp.5 for ; Sun, 27 Dec 2020 11:11:24 -0800 (PST) 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=Ohb32uzcS/LeiKiiZFbFPeuHgRiTaoVopnN4csPRE9o=; b=MYNuffz3lgy4agP2hGvR7CEdnGso75d96JTv7IFLoX7RFR0rfjAYubuMCm6OrsRc3C fPm4TlszoSoiwkRmIzach5stXq6Duru6MkoVW6P7jYLkeNkOjEKJMX2hl85uBjUuF0pp C540d6ImAcu2U84wkp6x1ec0uls9wF2LnnyxJWUQEs3oI4sJAO9Q4MUk3kzlJHHKmfiq M1BarBjhAd9HX07LQqT32BFzDtfretrUnPCss1BY/qZNSRAY6eHYq+j0DGyIyTCdPxci k3CfhWLDV7cPkC3rsjs7uWluhyxLjWF7xQWrIFUwBZVe/Y/B4GxviUW6551hxSkcAC4k Amrw== 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=Ohb32uzcS/LeiKiiZFbFPeuHgRiTaoVopnN4csPRE9o=; b=ZaRjpb9DyFiBHnu74LDL6LQT4Vm9z+00L8XyhOttVIQuhUDcprjPzgmXKqSsWcKtQW 1CDCIfUubdNiwMVGftAtHtQl5xb7D67R0SOoihqyFBU2p6SoCSw8EIqTpJDcSjPrIQYn 4O8f9TA/YtHxf9ec4Dm2JjyfLSFtqv5gC7AxBC3nUZNZicTxP+6HYbE2PJ+I3VaRq4xi cRClEhSRzn8lGe+8+lgO71Irv66xCTllbrwX7S98n5+QwAS4l74yzarheYoxo5fRyElo DzJgLUrUAUcZiB8oiyEFQ6FuWnUt69gvjx+js9vZXdlRrc/nl+PE7IGOhPuqoy+O8yCc 2f8Q== X-Gm-Message-State: AOAM5325S7cbjQCjv4BHRFAEmAsCZny27tG60BaV8+PhSER/205duZxu QDgdrKshzr/bxezr60gQ7WIHBhr/ztIG5zt/31E= X-Google-Smtp-Source: ABdhPJwKYwjf9UzXJ9THiOHjCLQE1c1fkqZJ8Gj1kDCR+q3iiATNWOHr1VZByVHczIzNCY4popRf25pBlNPbpx3ruRw= X-Received: by 2002:a67:2e16:: with SMTP id u22mr27342906vsu.12.1609096283985; Sun, 27 Dec 2020 11:11:23 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::e2e; envelope-from=yurivkhan@gmail.com; helo=mail-vs1-xe2e.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:126818 Archived-At: On Mon, 28 Dec 2020 at 00:55, Jean Louis wrote: > Would this concept be possible in Emacs Lisp: > > (defun my-function (arg &optional arg-1 arg-2) > (call-other-function (this-function-called parameters-to-this-function)= )) > > Then the other function would receive something like > > (my-function ARGUMENTS) > > Purpose of this is for `tabulated-list-mode' to know how to refresh > it. As the mode could be called by plethora of various ways. It would > be best if I could detect how function was called, with which > parameters and record the fact so that by the key the same function > may be called again. Firstly, =E2=80=98tabulated-list-mode=E2=80=99 should probably never be =E2= =80=9Ccalled=E2=80=9D as such. Instead, modes should be derived from it. (In OOP terms, =E2=80=98tabulated-list-mode=E2=80=99 should be treated as an abstract base= class.) =E2=80=98tabulated-list-mode=E2=80=99 is derived from =E2=80=98special-mode= =E2=80=99 which binds the =E2=80=98g=E2=80=99 key to =E2=80=98revert-buffer=E2=80=99. The behavior of= =E2=80=98revert-buffer=E2=80=99 is customized by setting =E2=80=98revert-buffer-function=E2=80=99 locally. =E2=80=98tabulated-list-mode=E2=80=99 sets =E2=80=98revert-buffer-function= =E2=80=99 to =E2=80=98tabulated-list-revert=E2=80=99. The behavior of =E2=80=98tabulated= -list-revert=E2=80=99 is customized by adding to =E2=80=98tabulated-list-revert-hook=E2=80=99. > Problem is not when there is one function or one report, I have > dynamic reports and varieties of reports invoked by variety of > functions and arguments. > > Or maybe there is other way of doing that? > > Should I just use local variables to remember the function and its > arguments so that I may invoke it from the report page? That is the way, I think. Be aware that setting a major mode kills all local variables. So you might want to structure your report mode and functions like this: (defvar-local my-report--context =E2=80=A6 "=E2=80=A6documentation=E2=80=A6") (defun my-report--revert () "=E2=80=A6documentation=E2=80=A6" (setq tabulated-list-entries =E2=80=A6something computed from my-report--context=E2=80=A6)) (define-derived-mode my-report-mode tabulated-list-mode "=E2=80=A6" "=E2=80=A6documentation=E2=80=A6" (add-hook 'tabulated-list-revert #'my-report--revert)) (defun my-report (=E2=80=A6args=E2=80=A6) "=E2=80=A6documentation=E2=80=A6" (with-current-buffer (=E2=80=A6generate a buffer name=E2=80=A6) (my-report-mode) (setq-local my-report--context =E2=80=A6some context built from arg= s=E2=80=A6) (revert-buffer)))