From e95100f1dceef67e0f9b2a31cf200d0f174eb8f6 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Tue, 23 Apr 2024 20:26:38 +0300 Subject: [PATCH] add set_fill_column (C-x f) --- src/js/ymacs-buffer.js | 2 +- src/js/ymacs-commands.js | 22 +++++++++++++++++++++- src/js/ymacs-keymap-emacs.js | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/js/ymacs-buffer.js b/src/js/ymacs-buffer.js index 6979329..48487ad 100644 --- a/src/js/ymacs-buffer.js +++ b/src/js/ymacs-buffer.js @@ -589,7 +589,7 @@ export class Ymacs_Buffer extends EventProxy { this.callHooks("onOverlayDelete", name); } - setMark(pos) { + setMark(pos = this.point()) { this.markMarker.setPosition(pos); } diff --git a/src/js/ymacs-commands.js b/src/js/ymacs-commands.js index 5671415..e4c522a 100644 --- a/src/js/ymacs-commands.js +++ b/src/js/ymacs-commands.js @@ -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); } @@ -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) ]----- */ diff --git a/src/js/ymacs-keymap-emacs.js b/src/js/ymacs-keymap-emacs.js index 6ddd75b..6ab094a 100644 --- a/src/js/ymacs-keymap-emacs.js +++ b/src/js/ymacs-keymap-emacs.js @@ -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",