Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust_src/remacs-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ extern "C" {
pub static Qframe: Lisp_Object;
pub static Qvector: Lisp_Object;
pub static Qchar_table: Lisp_Object;
pub static Qcategory_table: Lisp_Object;
pub static Qbool_vector: Lisp_Object;
pub static Qhash_table: Lisp_Object;
pub static Qthread: Lisp_Object;
Expand Down
22 changes: 22 additions & 0 deletions rust_src/src/category.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! Routines to deal with category tables.

use remacs_macros::lisp_fn;
use remacs_sys::Qcategory_table;
use lisp::LispObject;
use threads::ThreadState;

/// Return t if ARG is a category table.
#[lisp_fn]
fn category_table_p(arg: LispObject) -> LispObject {
LispObject::from_bool(arg.as_char_table().map_or(false, |table| {
LispObject::from_raw(table.purpose).eq(unsafe { LispObject::from_raw(Qcategory_table) })
}))
}

/// Return the current category table.
/// This is the one specified by the current buffer.
#[lisp_fn]
fn category_table() -> LispObject {
let buffer_ref = ThreadState::current_buffer();
LispObject::from_raw(buffer_ref.category_table)
}
6 changes: 6 additions & 0 deletions rust_src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mod process;
mod fonts;
mod threads;
mod chartable;
mod category;

#[cfg(all(not(test), target_os = "macos"))]
use alloc_unexecmacosx::OsxUnexecAlloc;
Expand Down Expand Up @@ -126,6 +127,9 @@ pub use buffers::Fcurrent_buffer;
// used in chartab.c
pub use chartable::Fset_char_table_parent;

// used in category.c
pub use category::Fcategory_table_p;

// Used in process.c
pub use str2sig::str2sig;
pub use process::Fget_process;
Expand Down Expand Up @@ -264,6 +268,8 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*chartable::Schar_table_subtype);
defsubr(&*chartable::Schar_table_parent);
defsubr(&*chartable::Sset_char_table_parent);
defsubr(&*category::Scategory_table_p);
defsubr(&*category::Scategory_table);

defsubr(&*floatfns::Sisnan);
defsubr(&*floatfns::Sacos);
Expand Down
20 changes: 0 additions & 20 deletions src/category.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,6 @@ it defaults to the current buffer's category table. */)

/* Category-table staff. */

DEFUN ("category-table-p", Fcategory_table_p, Scategory_table_p, 1, 1, 0,
doc: /* Return t if ARG is a category table. */)
(Lisp_Object arg)
{
if (CHAR_TABLE_P (arg)
&& EQ (XCHAR_TABLE (arg)->purpose, Qcategory_table))
return Qt;
return Qnil;
}

/* If TABLE is nil, return the current category table. If TABLE is
not nil, check the validity of TABLE as a category table. If
valid, return TABLE itself, but if not valid, signal an error of
Expand All @@ -197,14 +187,6 @@ check_category_table (Lisp_Object table)
return table;
}

DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0,
doc: /* Return the current category table.
This is the one specified by the current buffer. */)
(void)
{
return BVAR (current_buffer, category_table);
}

DEFUN ("standard-category-table", Fstandard_category_table,
Sstandard_category_table, 0, 0, 0,
doc: /* Return the standard category table.
Expand Down Expand Up @@ -504,8 +486,6 @@ See the documentation of the variable `word-combining-categories'. */);
defsubr (&Sdefine_category);
defsubr (&Scategory_docstring);
defsubr (&Sget_unused_category);
defsubr (&Scategory_table_p);
defsubr (&Scategory_table);
defsubr (&Sstandard_category_table);
defsubr (&Scopy_category_table);
defsubr (&Smake_category_table);
Expand Down