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 window-minibuffer-p #319

Merged
merged 5 commits into from
Sep 25, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions rust_src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ pub use interactive::Fprefix_numeric_value;
pub use editfns::Fbolp;
pub use editfns::Feolp;

// Used in minibuffer.c
pub use windows::Fwindow_minibuffer_p;

extern "C" {
fn defsubr(sname: *const Lisp_Subr);
}
Expand All @@ -218,6 +221,7 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*buffers::Soverlay_end);
defsubr(&*buffers::Soverlay_buffer);
defsubr(&*windows::Swindowp);
defsubr(&*windows::Swindow_minibuffer_p);
defsubr(&*windows::Swindow_live_p);
defsubr(&*windows::Swindow_point);
defsubr(&*windows::Sselected_window);
Expand Down
19 changes: 19 additions & 0 deletions rust_src/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use editfns::point;

pub type LispWindowRef = ExternalPtr<Lisp_Window>;

const FLAG_MINI: u16 = 1 << 0;

impl LispWindowRef {
/// Check if window is a live window (displays a buffer).
/// This is also sometimes called a "leaf window" in Emacs sources.
Expand All @@ -30,6 +32,11 @@ impl LispWindowRef {
pub fn start_marker(self) -> LispObject {
LispObject::from_raw(self.start)
}

#[inline]
pub fn is_minibuffer(&self) -> bool {
self.flags & FLAG_MINI != 0
}
}

/// Return t if OBJECT is a window and nil otherwise.
Expand Down Expand Up @@ -116,3 +123,15 @@ pub fn window_start(window: LispObject) -> LispObject {
};
marker_position(win.as_live_window_or_error().start_marker())
}

/// Return non-nil if WINDOW is a minibuffer window.
/// WINDOW must be a valid window and defaults to the selected one.
#[lisp_fn(min = "0")]
pub fn window_minibuffer_p(window: LispObject) -> LispObject {
let win = if window.is_nil() {
selected_window()
} else {
window
};
LispObject::from_bool(win.as_window_or_error().is_minibuffer())
}
10 changes: 0 additions & 10 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,6 @@ If FRAME is omitted or nil, it defaults to the selected frame. */)
return FRAME_MINIBUF_WINDOW (decode_live_frame (frame));
}

DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
Swindow_minibuffer_p, 0, 1, 0,
doc: /* Return non-nil if WINDOW is a minibuffer window.
WINDOW must be a valid window and defaults to the selected one. */)
(Lisp_Object window)
{
return MINI_WINDOW_P (decode_valid_window (window)) ? Qt : Qnil;
}

/* Don't move this to window.el - this must be a safe routine. */
DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW.
Expand Down Expand Up @@ -7666,7 +7657,6 @@ displayed after a scrolling operation to be somewhat inaccurate. */);
Vfast_but_imprecise_scrolling = false;

defsubr (&Sminibuffer_window);
defsubr (&Swindow_minibuffer_p);
defsubr (&Swindow_frame);
defsubr (&Sframe_root_window);
defsubr (&Sframe_first_window);
Expand Down