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

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

merged 1 commit into from Jul 29, 2017
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension

Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions rust_src/src/
@@ -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;

Expand Down Expand Up @@ -107,8 +108,11 @@ pub fn get_buffer(buffer_or_name: LispObject) -> LispObject {
/// Return the current buffer as a Lisp object.
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))
buffer_ref.as_ptr() as *mut c_void,
1 change: 1 addition & 0 deletions rust_src/src/
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions rust_src/src/
@@ -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) }