From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Making ielm behave like a shell (getting to previous commands using the up-arrow key) Date: Fri, 18 Dec 2020 21:36:42 +0300 Message-ID: References: <87im91ys4m.fsf@web.de> <874kklyqi2.fsf@web.de> <87im90dq2s.fsf@web.de> <87mtyb32ud.fsf@web.de> <5f8911eb-b20c-400e-86c6-a6ea6ca3d437@default> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32907"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: Michael Heerdegen , help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 18 19:42:58 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 1kqKiP-0008Su-L0 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 18 Dec 2020 19:42:57 +0100 Original-Received: from localhost ([::1]:45188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqKiO-0005zM-L4 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 18 Dec 2020 13:42:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqKgn-0005kT-WA for help-gnu-emacs@gnu.org; Fri, 18 Dec 2020 13:41:18 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:41385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqKga-0007GE-3M for help-gnu-emacs@gnu.org; Fri, 18 Dec 2020 13:41:16 -0500 Original-Received: from localhost ([::ffff:41.202.241.37]) (AUTH: PLAIN securesender, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E52B.000000005FDCF7B9.00002E09; Fri, 18 Dec 2020 11:40:57 -0700 Content-Disposition: inline In-Reply-To: <5f8911eb-b20c-400e-86c6-a6ea6ca3d437@default> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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:126521 Archived-At: * Drew Adams [2020-12-18 20:14]: > > First step: > > > > (let* ((mailing-hash (rcd-db-table-id-hash "mailinglistoptions" option *cf*)) > > (mid (gethash 'mailinglistoptions_accounts mailing-hash)) > > (mid-hash (rcd-db-table-id-hash "accounts" mid *cf*)) > > (accounts-hash (rcd-db-table-id-hash "accounts" mid *cf*)) > > (email-list (rcd-email-list mid)))) > > > > Second step: > > > > (let* ((setq mailing-hash (rcd-db-table-id-hash "mailinglistoptions" option *cf*)) > > (mid (gethash 'mailinglistoptions_accounts mailing-hash)) > > (mid-hash (rcd-db-table-id-hash "accounts" mid *cf*)) > > (accounts-hash (rcd-db-table-id-hash "accounts" mid *cf*)) > > (email-list (rcd-email-list mid)))) > > Nope. That raises an error telling you > "`let' bindings can have only one value-form". It was description of my way of debugging programs. I learned it online from Common Lisp. As I live isolated and not together in one room with any programmer neither I know ANY in this city and country where I am located I might catch something that is not common and continue with it for years just as it would be common. You cannot evaluate those forms alone or whole, as that is just description of step by step debugging. Programs do not run with `setq' there, it is inserted temporary to assign some variables step by step until I find what is wrong. That way of debugging worked well for me. But now I explore much easier edebug-defun, but I do not know how to stop edebugging. > FYI, that `let' has an empty body - it has only bindings. Because it was demonstration of step by step rather rudimentary debugging method. The whole function works just fine, I know that as 3917 emails were sent by using it. > More importantly, this "binding" is erroneous: > > (setq mailing-hash (rcd-db-table-id-hash ...)) That was demonstration. I insert `setq' to bind temporarily `mailing-hash' during my debugging process. I wish I would know before about edebug-defun, but I did not. After inserting setq, I would delete it. My habit is so strong that I may continue doing that for months until I get into edebug-defun > CAN you use a `setq' or other procedural code inside > a let-binding? Sure, if you want to. Just provide a > variable to bind to it. > > (let* ((fred 42) > (_IGNORED (setq fred 'nope-24)) > (_NADA (message "FRED: %S" fred))) > ;; Empty body, if you like > ) > > (Nothing special about the variable names. But an > underscore prefix is sometimes used conventionally > to tell human readers that the thingy isn't really > used or isn't used in some particular way. Here, > I use it to tell myself that the variable is used > only to be able to evaluate some sexp for its side > effect. And I use uppercase just to make this > weirdness more obvious to myself.) I have seen it works with _ alone > You can also bind the same variable multiple times, > if you like: > > (let* ((fred 42) > (alice (foo fred)) > (fred (if (> fred 0) 24 'derf)) > (fred '(nah dont-do-that at-all))) > (message "FRED: %S" fred)) Of course, I do that. > IOW: > > You can put any kind of procedural code in a `let' body > or a `let' binding. If in a binding, it needs to be as > a sexp to evaluate and bind to some variable. Only it does not look nice any more. So often I will jump out of first let and continue with second let. > You can use multiple, sequential bindings for the same > variable, if you use `let*'. Which * joker symbol I often forget. That is my major error in Elisp. > > Third step: > > > > (let* ((mailing-hash (rcd-db-table-id-hash "mailinglistoptions" option *cf*)) > > (setq mid (gethash 'mailinglistoptions_accounts mailing-hash)) > ^^^^^^^^^^^^^^^^^^^... > Same problem as above. That is some misunderstanding. I hope you got it now. How do you debug? You use edebug-defun? > > How would you do message calls there? > > See above. Put any procedural code you want to use > in the bindings part into a binding: provide a var > that you use or don't use, binding it to the code > you want to evaluate for its side effects. > > Is this kind of thing great style? Maybe not. But > you can do it. > > Being able to add `message' calls wherever you want > can be helpful. That I did not understand. Why now show example of message call? What is it? Do you mean (message something)? > Another thing you can add, as an alternative to > `message' calls, are calls to `debug'. Those are > essentially breakpoints. They let you know which > branch of code gets executed, opening the debugger > when encountered. > > (let* ((fred 42) > (_ZIP (setq fred 'nope-24)) > (_NADA (when (toto) (debug nil fred)))) > (unless (titi) (debug)) > ;;... > ) > > `C-h f debug'... Useful function. Is there anyway to get out of debug and continue the function? c does not do what I think it should do. I would like to exit out of debug and continue with the function. Any way?