Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export lem-base::*current-buffer*? #1152

Closed
kchanqvq opened this issue Nov 6, 2023 · 3 comments
Closed

Export lem-base::*current-buffer*? #1152

kchanqvq opened this issue Nov 6, 2023 · 3 comments

Comments

@kchanqvq
Copy link
Contributor

kchanqvq commented Nov 6, 2023

What is the current way to temporarily change (current-buffer) (like with-current-buffer in Emacs)? Although setter to current-buffer is exported, implementing with-current-buffer using the setter is not thread-safe. The best way seems to be just bind *current-buffer*, however currently it is internal to lem-base which suggest it is only used for internal implementation. Can we export this symbol instead?

@cxxxr
Copy link
Member

cxxxr commented Nov 6, 2023

I believe that active use of dynamic scopes should be avoided except in a few cases, such as testing.
I don't think dynamic scope is necessary since the operator provided by lem explicitly specifies the arguments, but what kind of case is there?

@kchanqvq
Copy link
Contributor Author

kchanqvq commented Nov 6, 2023

I agree with you from language design view point, that one should pass buffer as argument (conveniently packaged in point objects) in favor of with-current-buffer and current-buffer. Being said that, lem already provides and exports current-buffer which seems mostly useful to the coding style that relies on current buffer as a dynamic context. Then it might as well export something equivalent to with-current-buffer.

The concrete use case is that I'm writing a compatibility layer to run Emacs Lisp directly on lem. I have got surprisingly far! Lem design seems to follow very closely to that of Emacs. (I'm not familiar with the design process of lem, is this intended?) I've ported quite a few Emacs functions relying on current-buffer, and I also need to port with-current-buffer. I can do still do that if lem-base::*current-buffer* is not exported -- I just need to maintain my own el-compat:*current-buffer* instead, but I find this awkward given that there's already lem-base:current-buffer and lem-base::*current-buffer*.

@cxxxr
Copy link
Member

cxxxr commented Nov 6, 2023

I see.
well, maybe it might be good idea to provide a with-current-buffer macro.

@cxxxr cxxxr closed this as completed in 6706736 Nov 6, 2023
cxxxr added a commit that referenced this issue Nov 6, 2023
Export with-current-buffer and with-buffer-point, close #1152
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants