Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8843389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:12:28+00:00 2026-06-14T11:12:28+00:00

I think this is possible in Common Lisp (through overloading setf ), but not

  • 0

I think this is possible in Common Lisp (through overloading setf), but not sure about Emacs Lisp.

What I want to do would be something like:

(setf (local variable) value)

where the form (local ...) would call some code I’ve written and return the symbol to use for setting its value slot.

EDIT: From looking at gv.el it seems like advising gv-get would do the job, but maybe there’s a better procedure for it?

EDIT2: Tried the suggestion from Stefan, close, but not good 🙁

(gv-define-setter local (value varname &optional buffer)
  `(with-current-buffer (or ,buffer (current-buffer))
     (setq ,varname ,value)))

which expands to:

(let* ((v bar))
 (with-current-buffer (or nil (current-buffer))
  (setq v 42)))

Obviously, not what I wanted. I was trying to do it with advising as mentioned above and with gv-define-expander, but there’s just too much quoting going on, and I can’t find a way to loose the let part of the expression with the redundant substitution.

EDIT3:

OK, unless I messed something seriously in the scope or the evaluation sequence of the value the variable will be set to, this seems to work:

(gv-define-expander local
  (lambda (do &rest args)
    (let ((varname (first args))
          (buffer (or (second args) '(current-buffer)))
          (value (funcall do nil #'identity)))
      `(with-current-buffer ,buffer
         (setq ,varname ,value)))))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:12:29+00:00Added an answer on June 14, 2026 at 11:12 am

    There’s gv-define-expander, gv-define-setter, and gv-define-simple-setter (in order of growing simplicity of use).

    You might want to try the 100% guaranteed untested code (note how I pass the with-current-buffer+setq to do rather than calling do with dummy arguments, so that this things has a chance to work when used with push).

    (gv-define-expander local
      (lambda (do &rest varname &optional buffer)
        (macroexp-let2 nil b buffer
          (funcall do `(buffer-local-value ',varname ,b)
                   (lambda (value)
                    `(with-current-buffer ,b
                       (setq ,varname ,value)))))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is another one of my I think it's not possible but I need
I dont think this is possible in c# but ill post it anyway. Given
I don't think this is possible but I thought I'd throw it out there.
Think: tiling my emacs window with eshells, a la xmonad. Is this possible? I
i would like to implement a TimeSpanPicker , but not in the common way
I'm not sure if this is on-topic or not here, but it's so specific
I dont think this is possible to do, so perhaps I need a totally
I don't think this is currently possible or if it's even a good idea,
I think this could be a very easy question for you. But I have
(I think this is a pretty basic question on OOP, but unfortunately I wasn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.