From: Jean Louis <bugs@gnu.support>
To: help-gnu-emacs@gnu.org
Subject: Re: Is there way to read function invoked and its parameters?
Date: Mon, 28 Dec 2020 22:58:52 +0300 [thread overview]
Message-ID: <X+o4/M5rMPcffjWx@protected.rcdrun.com> (raw)
In-Reply-To: <3fb924a1-794e-43f7-bdea-d95a383c448a@default>
* Drew Adams <drew.adams@oracle.com> [2020-12-28 19:41]:
> > > > Reading quickly, so perhaps not understanding the request.
> > > > But I'm guessing that advice is what you're looking for.
>
> Still not reading this thread carefully, but I
> still have the impression that, for what you want
> to do, you can use _advice_.
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html
>
> When a function gets called you can do anything,
> including introspect the current context,
> reporting on it, and reinvoking the called arg
> (with the same or different args). Pretty much
> anything.
A more advanced example would be to trace the calls to the process
filter of a process PROC:
(defun my-tracing-function (proc string)
(message "Proc %S received %S" proc string))
(add-function :before (process-filter PROC) #'my-tracing-function)
Maybe you mean similar to that above.
The `process-filer' would be called multiple times by multiple other
functions in the same time and it would mean that I need somehow to
invoke `add-function' dynamically so that each new buffer receives the
"updating function".
This function here is mostly the final function that shall receive
information how to update the entries when entries are edited,
modified, it should invoke new SQL query to fetch fresh entries.
(defun rcd-db-report (title entries format table sort-key)
(let* ((title (generate-new-buffer-name (concat "RCD Database: " title))))
(let* ((buffer title)
(buffer (get-buffer-create buffer))
(mode-map (rcd-db-table-mode-map table)))
;; (message "Keymap: %s" table)
(switch-to-buffer-other-window buffer)
(delete-other-windows)
(setq tabulated-list-format format)
(setq tabulated-list-entries entries)
(setq rcd-db-edited-table table)
(rcd-db-list-mode) ;; TODO if I move it from this line, weird things happen
(use-local-map mode-map) ;; TODO if I move it from this line, weird things happen
(tabulated-list-init-header)
(setq tabulated-list-padding 1))
(setq tabulated-list-sort-key sort-key)
;;(tabulated-list-init-header)
(tabulated-list-print t)))
Then there is plethora of other functions that are hoping over
`rcd-db-sql-report-two' (but i could remove hops) and invoking the
above function.
(defun cf-tabulated-accounts-list ()
(interactive)
(let* ((sql "SELECT accounts_id, accounts_name FROM accounts"))
(rcd-db-sql-report-two "Accounts" sql [("ID" 5 t) ("Account" 80 t)] "accounts" nil)))
(defun cf-tabulated-accounts-without-country ()
(interactive)
(let* ((sql "SELECT accounts_id, accounts_name FROM accounts WHERE accounts_billingcountry IS NULL"))
(rcd-db-sql-report-two "Accounts" sql [("ID" 5 t) ("Account" 80 t)] "accounts" nil)))
(defun cf-tabulated-account (id)
(let* ((sql (format "SELECT accounts_id, accounts_name FROM accounts WHERE accounts_id = %s" id)))
(rcd-db-sql-report-two "Accounts" sql [("ID" 5 t) ("Account" 80 t)] "accounts" nil)))
Let us say there is invoked function `(cf-tabulated-account 2)' then
one solution that I can think of is to pass it as in the arguments,
maybe making a macro out of it.
(defun cf-tabulated-account (id)
(let* ((sql (format "SELECT accounts_id, accounts_name FROM accounts WHERE accounts_id = %s" id)))
(rcd-db-sql-report-two "Accounts" sql [("ID" 5 t) ("Account" 80 t)] "accounts" nil `'(cf-tabulated-account ,id))))
Then it would arrive to first function to be invoked to refresh the entries.
Just thinking how to do it right. It requires a lot of changes to many various functions.
next prev parent reply other threads:[~2020-12-28 19:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<courier.000000005FE8CA54.00006BFB@stw1.rcdrun.com>
2020-12-27 18:20 ` Is there way to read function invoked and its parameters? Drew Adams
2020-12-27 18:39 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-28 6:57 ` Jean Louis
2020-12-28 16:40 ` Drew Adams
2020-12-28 19:58 ` Jean Louis [this message]
2020-12-27 17:54 Jean Louis
2020-12-27 18:04 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-27 19:11 ` Yuri Khan
2020-12-28 7:07 ` Jean Louis
2020-12-28 9:04 ` Yuri Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=X+o4/M5rMPcffjWx@protected.rcdrun.com \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).