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

Port get-process #256

Merged
merged 6 commits into from
Jul 22, 2017
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 @@ -1149,6 +1149,7 @@ extern "C" {
pub static Qfont_object: Lisp_Object;
pub static lispsym: Lisp_Symbol;
pub static Vbuffer_alist: Lisp_Object;
pub static Vprocess_alist: Lisp_Object;

pub fn Fcons(car: Lisp_Object, cdr: Lisp_Object) -> Lisp_Object;
pub fn Fcurrent_buffer() -> Lisp_Object;
Expand Down
3 changes: 3 additions & 0 deletions rust_src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod multibyte;
mod buffers;
mod windows;
mod interactive;
mod process;

#[cfg(all(not(test), target_os = "macos"))]
use alloc_unexecmacosx::OsxUnexecAlloc;
Expand Down Expand Up @@ -120,6 +121,7 @@ pub use crypto::sha512_buffer;

// Used in process.c
pub use str2sig::str2sig;
pub use process::Fget_process;

// Used in character.c
pub use multibyte::char_resolve_modifier_mask;
Expand Down Expand Up @@ -148,6 +150,7 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*buffers::Sget_buffer);
defsubr(&*windows::Swindowp);
defsubr(&*windows::Swindow_live_p);
defsubr(&*process::Sget_process);
defsubr(&*lists::Satom);
defsubr(&*lists::Slistp);
defsubr(&*lists::Snlistp);
Expand Down
2 changes: 1 addition & 1 deletion rust_src/src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn assq(key: LispObject, list: LispObject) -> LispObject {
///
/// Equality is defined by TESTFN is non-nil or by `equal' if nil.
#[lisp_fn(min = "2")]
fn assoc(key: LispObject, list: LispObject, testfn: LispObject) -> LispObject {
pub fn assoc(key: LispObject, list: LispObject, testfn: LispObject) -> LispObject {
for tail in list.iter_tails() {
let item = tail.car();
if let Some(item_cons) = item.as_cons() {
Expand Down
21 changes: 21 additions & 0 deletions rust_src/src/process.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Functions operating on process.

use remacs_macros::lisp_fn;
use remacs_sys::Vprocess_alist;
use lisp::LispObject;
use lists::{assoc, cdr};

/// Return the process named NAME, or nil if there is none.
#[lisp_fn]
fn get_process(name: LispObject) -> LispObject {
if name.is_process() {
name
} else {
name.as_string_or_error();
cdr(assoc(
name,
LispObject::from_raw(unsafe { Vprocess_alist }),
LispObject::constant_nil(),
))
}
}
14 changes: 1 addition & 13 deletions src/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static Lisp_Object chan_process[FD_SETSIZE];
static void wait_for_socket_fds (Lisp_Object, char const *);

/* Alist of elements (NAME . PROCESS). */
static Lisp_Object Vprocess_alist;
Lisp_Object Vprocess_alist;

/* Buffered-ahead input char from process, indexed by channel.
-1 means empty (no char is buffered).
Expand Down Expand Up @@ -929,24 +929,13 @@ free_dns_request (Lisp_Object proc)
}
#endif


DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,
doc: /* Return t if OBJECT is a process. */)
(Lisp_Object object)
{
return PROCESSP (object) ? Qt : Qnil;
}

DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0,
doc: /* Return the process named NAME, or nil if there is none. */)
(register Lisp_Object name)
{
if (PROCESSP (name))
return name;
CHECK_STRING (name);
return Fcdr (Fassoc (name, Vprocess_alist, Qnil));
}

/* This is how commands for the user decode process arguments. It
accepts a process, a process name, a buffer, a buffer name, or nil.
Buffers denote the first process in the buffer, and nil denotes the
Expand Down Expand Up @@ -7918,7 +7907,6 @@ The variable takes effect when `start-process' is called. */);
Vprocess_adaptive_read_buffering = Qt;

defsubr (&Sprocessp);
defsubr (&Sget_process);
defsubr (&Sdelete_process);
defsubr (&Sprocess_status);
defsubr (&Sprocess_exit_status);
Expand Down