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

Define a thread_state type and the current-buffer function #253

Merged
merged 1 commit into from Jul 29, 2017
Jump to file or symbol
Failed to load files and symbols.
+20 −4
Diff settings

Always

Just for now

Copy path View file
@@ -1,11 +1,12 @@
//! Functions operating on buffers.
use libc::{c_uchar, ptrdiff_t};
use libc::{c_void, c_uchar, ptrdiff_t};
use lisp::{LispObject, ExternalPtr};
use remacs_sys::{Lisp_Buffer, Lisp_Type, Vbuffer_alist, current_thread, make_lisp_ptr};
use remacs_sys::{Lisp_Buffer, Lisp_Type, Vbuffer_alist, make_lisp_ptr};
use strings::string_equal;
use lists::{car, cdr};
use threads::ThreadState;
use remacs_macros::lisp_fn;
@@ -107,8 +108,11 @@ pub fn get_buffer(buffer_or_name: LispObject) -> LispObject {
/// Return the current buffer as a Lisp object.
#[lisp_fn]
pub fn current_buffer() -> LispObject {
let buffer_ref = ThreadState::current_buffer();
unsafe {
let buffer_ref = (*current_thread).m_current_buffer;
LispObject::from_raw(make_lisp_ptr(buffer_ref, Lisp_Type::Lisp_Vectorlike))
LispObject::from_raw(make_lisp_ptr(
buffer_ref.as_ptr() as *mut c_void,
Lisp_Type::Lisp_Vectorlike,
))
}
}
Copy path View file
@@ -44,6 +44,7 @@ mod windows;
mod interactive;
mod process;
mod fonts;
mod threads;
#[cfg(all(not(test), target_os = "macos"))]
use alloc_unexecmacosx::OsxUnexecAlloc;
Copy path View file
@@ -0,0 +1,11 @@
use std::mem;
use remacs_sys::current_thread;
use buffers::LispBufferRef;
pub struct ThreadState {}
impl ThreadState {
pub fn current_buffer() -> LispBufferRef {
unsafe { mem::transmute((*current_thread).m_current_buffer) }
}
}
ProTip! Use n and p to navigate between commits in a pull request.