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
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -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);
}
@@ -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);
@@ -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.
@@ -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.
@@ -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())
}
@@ -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.
@@ -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);
ProTip! Use n and p to navigate between commits in a pull request.