Gnus development mailing list
 help / color / mirror / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: ding@gnus.org
Subject: [misunderstanding] (was: for a given emacs session: insert a subject with an increasing counter)
Date: Sat, 04 Sep 2021 17:30:42 +0200	[thread overview]
Message-ID: <87r1e473z1.fsf_-_@mat.ucm.es> (raw)
In-Reply-To: <87bl5dbof1.fsf@tullinup.koldfront.dk>

[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]


> Uwe writes:

> Ah, yes, but setq doesn't define a quantity - it is much less abstract:
> it assigns a value to a variable.


> Thanks for explaining, I was genuinely puzzled; you are using a
> different definition of recursion than most people do, when it comes to
> programming - where it is usually, implicitly about functions.

I realised that there was a misunderstanding. I thought you and others
suggest just to use 

(defun my-new-insert-subject-counter-old ()
  "Insert a string of the form [`counter/Total'] "
  (interactive)
  (save-excursion
    (setq my-subject-counter (+ my-subject-counter 1))
    (let ((total (read-string "Total number: " )))
    (message-carefully-insert-headers (list (cons 'Subject (format "[%s/%s]" my-subject-counter total)))))))

Without 
(defvar my-subject-counter 0) (or something like this.)

As a matter of fact I deleted the defvar definition from my code and it
still worked[1] but which puzzled me.

So I thought 
    (setq my-subject-counter (+ my-subject-counter 1))

defines and sets the variable in a recursive way, but it does not. You
need a defvar (or a surrounding let). 

I only discovered my error misunderstanding when I restarted emacs and
the code did not work anymore

Sorry for the misunderstanding.


Footnotes:
[1]  because it was already defined


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

  parent reply	other threads:[~2021-09-04 15:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 16:01 for a given emacs session: insert a subject with an increasing counter Uwe Brauer
2021-08-30 16:10 ` Eric S Fraga
2021-08-30 18:46   ` Eric Abrahamsen
2021-08-31  6:50   ` Uwe Brauer
2021-08-31  6:58     ` Adam Sjøgren
2021-08-31 15:42       ` Uwe Brauer
2021-08-31 15:54         ` Adam Sjøgren
2021-09-02  8:15           ` Uwe Brauer
2021-09-04 15:30           ` Uwe Brauer [this message]
2021-09-07 20:04             ` [misunderstanding] (was: for a given emacs session: insert a subject with an increasing counter) Emanuel Berg
2021-09-01  3:55         ` for a given emacs session: insert a subject with an increasing counter Bodertz
2021-09-04 15:25           ` Uwe Brauer
2021-09-07 17:12             ` Emanuel Berg
2021-09-07 19:02               ` Eric Abrahamsen
2021-09-07 19:25                 ` Emanuel Berg
2021-09-07 20:09                   ` Emanuel Berg
2021-09-07 20:35                     ` Emanuel Berg
2021-09-07 20:44                     ` Eric Abrahamsen
2021-09-21  3:32                       ` Emanuel Berg
2021-09-21 19:12                         ` Bodertz
2021-09-21 21:56                           ` Emanuel Berg
2021-08-31  7:44     ` Emanuel Berg
2021-08-31  7:56       ` Emanuel Berg
2021-08-31 16:01       ` Uwe Brauer
2021-08-31 16:29         ` Eric Abrahamsen
2021-08-31 19:06           ` Uwe Brauer

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1e473z1.fsf_-_@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=ding@gnus.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 NNTP newsgroup(s).