Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions TeXmacs/progs/generic/search-widgets.scm
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,19 @@ tree 或 #f
(perform-search*)
(set! isreplace? #t))))

(tm-define (replace-all-occurrences . args)
(let ((u (if (null? args) (master-buffer) (car args)))
(raux (if (null? args) (replace-buffer) (cadr args))))
(and-with by (or (by-tree raux) current-replace)
Comment on lines +707 to +710
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argument parsing in replace-all-occurrences is unsafe: when args is non-empty but has only one element, (cadr args) will throw. Since the procedure signature is variadic (. args), either enforce exactly 0 or 2 args (and signal a clear error) or make raux default when (length args) < 2.

Copilot uses AI. Check for mistakes.
(with-buffer u
(search-extreme-match #f)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace-all already accepts an explicit target buffer u, but this new call to search-extreme-match does not pass it, so search-extreme-match will default to (master-buffer) instead. If replace-all is invoked programmatically with a buffer that differs from master-buffer (or if master-buffer is #f), the cursor navigation can happen in the wrong buffer and the replace loop will then run in u with inconsistent search state. Prefer calling search-extreme-match with u (or call extreme-search-result directly inside with-buffer u) to guarantee it operates on the same buffer being edited.

Suggested change
(search-extreme-match #f)
(search-extreme-match u #f)

Copilot uses AI. Check for mistakes.
(start-editing)
(while (replace-next by)
(perform-search*))
(end-editing))
(perform-search*)
(set! isreplace? #t))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Customized keyboard shortcuts in search and replace modes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -938,6 +951,8 @@ tree 或 #f
"Replace all further occurrences (Command+Enter)"
"Replace all further occurrences (Ctrl+Enter)")))
(replace-all u raux))
((balloon (icon "tm_replace_all.xpm") "Replace all occurrences")
(replace-all-occurrences u raux))
>>>
(=> (balloon (icon "tm_preferences.xpm")
"Search and replace preferences")
Expand Down Expand Up @@ -977,6 +992,8 @@ tree 或 #f
(replace-one))
((balloon (icon "tm_replace_all.xpm") "Replace all further occurrences")
(replace-all))
((balloon (icon "tm_replace_all.xpm") "Replace all occurrences")
(replace-all-occurrences))
>>>
(=> (balloon (icon "tm_preferences.xpm")
"Search and replace preferences")
Expand Down Expand Up @@ -1178,6 +1195,8 @@ tree 或 #f
(replace-one))
((balloon (icon "tm_replace_all.xpm") "Replace all further occurrences")
(replace-all))
((balloon (icon "tm_replace_all.xpm") "Replace all occurrences")
(replace-all-occurrences))
>>>
((check (balloon (icon "tm_filter.xpm") "Only show paragraphs with hits")
"v" (search-filter-enabled?))
Expand Down
53 changes: 30 additions & 23 deletions devel/202_105.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
# [202_105] "Meta" will appear in the keyboard shortcut notification pop-up

### How to test
1. Open Mogan on Linux
2. Open a new empty document
3. Press `Tab` key
4. Verify the notification shows "Use Super+Tab in order to insert a tab" (not "Meta+Tab")
# [202_105] Search and replace: add "Replace all occurrences" button

## How to test
1. Open a document with multiple occurrences of a word (e.g. "hello" appearing 5 times)
2. Open search and replace (Edit → Search and replace)
3. Place cursor in the middle of the document (e.g. after the 3rd occurrence)
4. Enter the search term "hello" and the replacement "world"
5. Click "Replace all further occurrences" (or press Ctrl+Enter / Command+Enter)
6. Confirm that only the occurrences **after the cursor** are replaced (original behavior preserved)
7. Undo, then click "Replace all occurrences"
8. Confirm that **all 5 occurrences** are replaced, including those before the cursor

## 2026/02/25
### What
Replace "Meta" with platform-appropriate key name in keyboard shortcut notification pop-ups:
- Linux: display "Super" instead of "Meta"
- Windows: display "Win" instead of "Meta"
- macOS: display "Command" instead of "Meta"
Add a separate "Replace all occurrences" button that replaces every match in the entire document, while keeping the original "Replace all further occurrences" button and behavior.

### Why
On Linux/Windows, the `M-` modifier key is displayed as "Meta" in notification messages like "Use Meta+Tab in order to insert a tab". Modern keyboards do not have a key labeled "Meta" — on Linux the key is labeled "Super" and on Windows it is labeled "Win". This confuses users who cannot identify which key to press.

Fixes: https://github.com/XmacsLabs/mogan/issues/2822
Users expect a way to replace every occurrence in the document regardless of cursor position (issue #2857). The maintainer requested this as a separate button so the original "Replace all further occurrences" behavior is preserved.

Comment on lines +16 to 20
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR metadata says "Fix replace-all to replace entire document" and mentions updating tooltips from "Replace all further occurrences" to "Replace all occurrences", but the implementation here describes adding a new "Replace all occurrences" action while keeping the original behavior/string. Please align the PR title/description (or this dev note) with the actual approach so reviewers/users aren’t misled about what changed.

Copilot uses AI. Check for mistakes.
### How
In `system_kbd_initialize` in `src/Texmacs/Server/tm_config.cpp`, changed the Qt branch mapping for `"M-"` from a single `localize("Meta::keyboard", true)` to platform-conditional:

```cpp
if (os_win ())
h ("M-") = localize ("Win::keyboard", true);
else if (os_macos ())
h ("M-") = localize ("Command::keyboard", true);
else
h ("M-") = localize ("Super::keyboard", true);
Added a new `replace-all-occurrences` function that calls `(search-extreme-match #f)` before the replace loop to navigate to the first match, so replacement starts from the beginning of the document. The original `replace-all` function is kept unchanged.

```scheme
(tm-define (replace-all-occurrences . args)
(let ((u (if (null? args) (master-buffer) (car args)))
(raux (if (null? args) (replace-buffer) (cadr args))))
(and-with by (or (by-tree raux) current-replace)
(with-buffer u
(search-extreme-match #f) ;; Go to the first match
(start-editing)
(while (replace-next by)
(perform-search*))
(end-editing))
(perform-search*)
(set! isreplace? #t))))
```

Also removed the now-unused `("meta::keyboard" "")` entry from `TeXmacs/plugins/lang/dic/en_US/zh_CN.scm`.


Loading