Skip to content

Commit

Permalink
add set_fill_column (C-x f)
Browse files Browse the repository at this point in the history
  • Loading branch information
mishoo committed Apr 24, 2024
1 parent 6aba61a commit e95100f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/ymacs-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ export class Ymacs_Buffer extends EventProxy {
this.callHooks("onOverlayDelete", name);
}

setMark(pos) {
setMark(pos = this.point()) {
this.markMarker.setPosition(pos);
}

Expand Down
22 changes: 21 additions & 1 deletion src/js/ymacs-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ Ymacs_Buffer.newCommands({
this.cmd("goto_char", eop);
done = true;
}
if (this._rowcol.col > this.getq("fill_column")) {
if (this._rowcol.col > this.getq("fill_column") + 1) {
if (p > bol) {
this.cmd("goto_char", p);
}
Expand Down Expand Up @@ -1222,6 +1222,26 @@ Ymacs_Buffer.newCommands({
});
}),

set_fill_column: Ymacs_Interactive("p", function(value){
let next = value => {
let prev = this.getq("fill_column");
this.setq("fill_column", +value);
this.signalInfo(`Fill column set to ${value} (was ${prev})`, false, 5000);
};
if (value == null) {
this.whenMinibuffer(mb => {
this.cmd("minibuffer_prompt", "Set fill column to: ");
mb.setMark();
mb.transientMarker = mb.createMarker(mb.point(), true);
mb.cmd("insert", String(this._rowcol.col));
mb.ensureTransientMark();
this.cmd("minibuffer_read_number", next);
});
} else {
next(value);
}
}),

});

/* -----[ rectangle functions (vertical editing) ]----- */
Expand Down
1 change: 1 addition & 0 deletions src/js/ymacs-keymap-emacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ let emacs_keys = Object.assign({}, minibuffer_keys, {
"M-^" : "delete_indentation",
"M-;" : "comment_dwim",
"C-x =" : "what_cursor_position",
"C-x f" : "set_fill_column",

// vertical editing
"C-x r t" : "string_rectangle",
Expand Down

0 comments on commit e95100f

Please sign in to comment.