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

Ported window-margins #351

Merged
merged 4 commits into from Oct 12, 2017
Jump to file or symbol
Failed to load files and symbols.
+30 −20
Diff settings

Always

Just for now

Copy path View file
@@ -241,6 +241,7 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*windows::Swindow_buffer);
defsubr(&*windows::Swindow_valid_p);
defsubr(&*windows::Swindow_start);
defsubr(&*windows::Swindow_margins);
defsubr(&*process::Sget_process);
defsubr(&*process::Sprocessp);
defsubr(&*process::Sprocess_name);
Copy path View file
@@ -2,9 +2,10 @@
use lisp::{LispObject, ExternalPtr};
use remacs_macros::lisp_fn;
use remacs_sys::{Lisp_Window, selected_window as current_window};
use remacs_sys::{EmacsInt, Lisp_Window, selected_window as current_window};
use marker::marker_position;
use editfns::point;
use libc::c_int;
pub type LispWindowRef = ExternalPtr<Lisp_Window>;
@@ -135,3 +136,30 @@ pub fn window_minibuffer_p(window: LispObject) -> LispObject {
};
LispObject::from_bool(win.as_window_or_error().is_minibuffer())
}
/// Get width of marginal areas of window WINDOW.
/// WINDOW must be a live window and defaults to the selected one.
///
/// Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
/// If a marginal area does not exist, its width will be returned
/// as nil.
#[lisp_fn(min = "0")]
pub fn window_margins(window: LispObject) -> LispObject {
fn margin_as_object(margin: c_int) -> LispObject {
if margin != 0 {
LispObject::from_fixnum(margin as EmacsInt)
} else {
LispObject::constant_nil()
}
}
let win = if window.is_nil() {
selected_window()
} else {
window
}.as_live_window_or_error();
LispObject::cons(
margin_as_object(win.left_margin_cols),
margin_as_object(win.right_margin_cols),
)
}
Copy path View file
@@ -6980,24 +6980,6 @@ Return t if any margin was actually changed and nil otherwise. */)
}
DEFUN ("window-margins", Fwindow_margins, Swindow_margins,
0, 1, 0,
doc: /* Get width of marginal areas of window WINDOW.
WINDOW must be a live window and defaults to the selected one.
Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
If a marginal area does not exist, its width will be returned
as nil. */)
(Lisp_Object window)
{
struct window *w = decode_live_window (window);
return Fcons (w->left_margin_cols
? make_number (w->left_margin_cols) : Qnil,
w->right_margin_cols
? make_number (w->right_margin_cols) : Qnil);
}
/***********************************************************************
Fringes
@@ -7742,7 +7724,6 @@ displayed after a scrolling operation to be somewhat inaccurate. */);
defsubr (&Sset_window_configuration);
defsubr (&Scurrent_window_configuration);
defsubr (&Sset_window_margins);
defsubr (&Swindow_margins);
defsubr (&Sset_window_fringes);
defsubr (&Swindow_fringes);
defsubr (&Sset_window_scroll_bars);
ProTip! Use n and p to navigate between commits in a pull request.