Skip to main content

Timeline for When use setq or set '

Current License: CC BY-SA 4.0

19 events
when toggle format what by license comment
Mar 23, 2020 at 20:10 comment added Tobias @Fólkvangr I tested yesterday and was surprised to see that the value of a variable set by (set '... ...) was void when tested in a different buffer. Don't know what the heck happened yesterday. My test today proved me wrong. Thanks for the correction. I'll delete my comment and write it anew without the fault. I'll just replace buffer locally with global. Nevertheless the main statement that with lexical-binding setq does more often the right thing because it sets the value of the uninterned symbol remains the same.
Mar 21, 2020 at 23:36 comment added Tobias @Fólkvangr I didn't want to demote setq with my previous comment. I rather wanted to promote it. In programs it does more often the right thing than (set '... ...) since setq is the right method to set local let-bound variables to a new value when lexical binding is active. On the other hand (set '... ...) always dynamically binds the value buffer locally. That is almost always wrong. The assigned new value is not visible within the let if the dynamical binding is shadowed by a lexical one. The right way to define such a variable is (defvar-local ...) on file-global scope.
S Mar 21, 2020 at 15:07 history suggested user19761 CC BY-SA 4.0
added a remark.
Mar 21, 2020 at 8:33 review Suggested edits
S Mar 21, 2020 at 15:07
Mar 21, 2020 at 6:16 comment added Tobias Note that the statement "setq is a convenience function for set" is deadly wrong. This is also documented in the doc strings I cited in my answer.
S Mar 20, 2020 at 11:58 history suggested user19761 CC BY-SA 4.0
review completed
Mar 20, 2020 at 5:43 vote accept Daniel
Mar 20, 2020 at 5:42 comment added Daniel @LoremIpsum: I see ... My bad. I was playing in the init file and am learning. I found about nil and 'nil and also t being true and not really being toggle. I got my nose now buried in learning Lisp. Again thank you! :-)
Mar 20, 2020 at 1:48 comment added Lorem Ipsum @Daniel, yes, in short, one is a function call, the other sets a variable. I'm not sure what you mean by "but that's incorrect". Can you please say a little more about what you mean? t does mean true; evaluate (if t (message "True!")). Everything but nil also evaluates as true (try putting different things in place of t). nil is indeed used for false. Quoting nil "returns its single argument, as written, without evaluating it", so 'nil returns nil. (See the links in @Fólkvangr's comment)
Mar 19, 2020 at 21:18 review Suggested edits
S Mar 20, 2020 at 11:58
Mar 19, 2020 at 20:16 comment added Daniel @LoremIpsum: Thanks for the work. So in short one is a function call and the other is setting a variable. I also though that t stood for true, but that's incorrect and setting false is actually done by stating 'nil with the quote. LISP is a bit confusing, but you certainly pushed me into a direction.
S Mar 19, 2020 at 19:39 history suggested user19761 CC BY-SA 4.0
Added context and did some corrections...
Mar 19, 2020 at 18:47 review Suggested edits
S Mar 19, 2020 at 19:39
Mar 19, 2020 at 17:54 comment added Lorem Ipsum Thank you. I put that there b/c I intend to update the answer, but can't at the moment.
Mar 19, 2020 at 16:09 comment added Drew Please remove this, and incorporate what's needed into the answer itself: the following contains some inaccuracies. See comments. Comments can be removed at any time. Questions and answers should stand on their own, without needing comments.
Mar 19, 2020 at 15:27 history edited Lorem Ipsum CC BY-SA 4.0
added 76 characters in body
Mar 19, 2020 at 15:26 comment added Lorem Ipsum My self-assessment is "advanced beginner", so I assumed there would be some errors. Thank you for pointing them out and for providing guidance, for @Daniel's sake and my own.
Mar 19, 2020 at 14:47 history edited Lorem Ipsum CC BY-SA 4.0
added 82 characters in body
Mar 19, 2020 at 14:39 history answered Lorem Ipsum CC BY-SA 4.0