| Age | Commit message (Collapse) | Author |
|
* greader-dict.el: Require 'greader instead of forward-declaring
greader--current-buffer, fixing byte-compilation of
greader-dict-tests.el.
(greader-dict-filters-prefix-map, greader-dict-prefix-map):
Initialize keymaps inline in defvar declarations instead of
mutating them with top-level define-key calls.
Bind "d" in greader-prefix-keymap directly.
* greader.el: Remove forward declaration of greader-dict-prefix-map
and the eval-after-load form that bound it, since greader-dict.el
now handles this itself.
Co-Authored-By: Stefan Monnier <monnier@iro.umontreal.ca>
|
|
* greader-dict.el (greader-dict--merge): Return KEY unchanged when
already merged, instead of nil; fixes nil key being inserted into
the hash table on duplicate merge attempts.
(greader-dict-merge--check-candidate): Fix inverted predicate logic
and broken path comparison (full path vs. nondirectory); use
expand-file-name for correct equality check.
(greader-dict-merge--dictionaries): Iterate over (cdr dictionaries)
to skip the main dictionary itself; call greader-dict-read-from-dict-file
directly to avoid circular dispatch through greader-dict-merge-dictionary.
(greader-dict-merge-dictionary): When called with FILENAME, update
greader-dict-merge-dictionaries-alist, pass merge=t to
greader-dict-read-from-dict-file, and respect greader-dict-merge-save.
(greader-dict-merge-save): Rename to greader-dict-merge-save-to-file
to avoid defcustom/defun namespace collision.
(greader-dict-mode): Call greader-dict-load-merges and
greader-dict-merge--dictionaries on startup to auto-reload saved merges.
(greader-dict-prefix-map): Bind "M" to greader-dict-merge-dictionary.
(greader-dict-filters-mode): Add forward declaration before
with-greader-dict-temp-buffer to suppress byte-compiler warning.
* greader-dict-tests.el: New file; 7 ERT tests covering
greader-dict--merged-p, greader-dict--merge, greader-dict-add with
merge flag, greader-dict-write-file skipping merged entries, and
greader-dict-merge-dictionary loading and updating the alist.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
This commit introduces a feature to merge multiple dictionary files.
This allows users to combine a primary dictionary with one or more auxiliary dictionaries (e.g., a personal word list) temporarily for a session or persistently across sessions, without modifying the main dictionary file.
Key changes:
- A new interactive command `greader-dict-merge-dictionary` allows merging another dictionary into the current one.
- Merged entries are marked with a `greader-dict-merged` text property and are not saved to the main dictionary file, ensuring the merge is non-destructive.
- Merge configurations are stored in `greader-dict-merge-dictionaries-alist` and can be saved persistently to a separate `.merges` file, controlled by the `greader-dict-merge-save` custom variable.
- `greader-dict-read-from-dict-file` and `greader-dict-add` were updated to handle the merging logic.
|
|
* greader-dict.el (greader-dict--get-key-from-word): Add optional
MATCHES argument. When provided, use it directly instead of
building a fresh temporary hash table of match-type entries on
every invocation. The new implementation iterates over the list
with `dolist', which avoids the O(m) allocation and copy that the
previous code performed for each word that had no direct entry in
`greader-dictionary'.
(greader-dict-check-and-replace): Pre-compute the list of
match-type keys once with `greader-dict--get-matches' and pass it
to `greader-dict--get-key-from-word' on every iteration of the
main word loop. This eliminates the repeated allocation that
occurred for each unmatched word in the sentence.
|
|
In "greader-dict--update", wrap the code that reads the dictionary
file from disk within an "unless greader-reading-mode" block.
This prevents the dictionary from being reloaded while the reader
is active, which could lead to inconsistent state or performance
issues during playback.
|
|
* greader-dict.el (greader-dict-toggle-filters): Add ;;;###autoload
cookie so that calling the obsolete alias before the library is
loaded triggers autoloading correctly.
|
|
|
|
Remove the "greader-dict-toggle-filters" variable alias, as it is
redundant with the function alias for "greader-dict-filters-mode".
|
|
Rename the "greader-dict-toggle-filters" minor mode to
"greader-dict-filters-mode" to align with Emacs naming conventions.
Obsolete aliases for the function and the variable are provided to
ensure backward compatibility. Internal references across the project
have been updated accordingly.
|
|
When processing a single word, greader-dict appends a newline to the
temporary buffer. This commit wraps the "newline" call in
"ignore-errors" to prevent potential failures from interrupting the
execution, especially if the buffer state is restricted.
|
|
When dictionary functions are executed from a temporary buffer, they
need to know the original buffer from which the lookup was initiated.
Previously, the variable "greader-dict--current-reading-buffer" was not
always correctly set, leading to issues where buffer-local values
(like the dictionary language) could not be found.
This change ensures that "greader--current-buffer" is prioritized when
available, and correctly propagates the reading buffer context into the
sandbox environment.
|
|
|
|
Adjust regexp escaping for "greader-dict-match-indicator" and
"greader-dict--item-type-alist" definitions. This change simplifies
the string representation by removing unnecessary backslashes, as "%"
is not a special character in Emacs Lisp strings unless used in a
format string.
|
|
To prevent byte-compiler warnings, remove the "(require 'greader)"
from "greader-dict.el" and introduce a "defvar" for
"greader--current-buffer" instead.
In "greader.el", add forward declarations for variables and functions
used from "greader-dict.el". This ensures the byte-compiler is aware
of them even if "greader-dict.el" is loaded later.
Additionally, reorder the "greader-study-set-position" function for
better code organization.
|
|
The greader-dict functions could fail when called from a buffer other than
the one where "greader-reading-mode" was active.
To solve this, "greader-dict.el" now uses the "greader--current-buffer"
variable to find the correct buffer. This variable is now set more
reliably via a new hook in "greader-reading-mode".
This change centralizes the logic for tracking the active reading buffer,
making dictionary operations more robust.
|
|
The change in greader-dict--update ensures that the correct reading
buffer is used when updating the dictionary.
Previously, (current-buffer) was used, which could lead to errors if
the update function was called from a different context than the
buffer being read.
The new implementation now prioritizes the value of
greader--current-buffer, falling back to (current-buffer) only if it
is not set. This improves the reliability of the dictionary update
mechanism.
|
|
The dictionary update process is now called from "greader-stop". This
ensures that "greader-dict--update" is executed once when reading stops,
making the update process more reliable.
In "greader-dict.el", the logic for applying filters has been simplified.
The function "greader-dict-check-and-replace" no longer fetches filter
variables from the reading buffer. This reduces coupling between the
dictionary and the reading buffer's local variables.
The docstring for "greader-stop" has been updated to document the new
behavior.
|
|
'5-greader-dict-mode-with-a-linux-to-gnu-plus-linux-rule-makes-greader-hang' into 'master'
Resolve "greader-dict-mode with a "Linux" to "GNU plus Linux" rule makes greader hang."
Closes #5
See merge request michelangelo-rodriguez/greader!14
|
|
This commit refactors the keybinding system to allow for greater user customization.
The hardcoded "C-r" prefix has been replaced with a new customizable variable, `greader-keymap-prefix`. Users can now set their preferred keybinding prefix in their configuration.
Key changes:
- A new `greader-keymap-prefix` customizable variable is introduced.
- Keymaps have been reorganized into a hierarchical structure using prefix maps (`greader-prefix-keymap`, `greader-dict-prefix-map`).
- A new interactive function, `greader-set-map-prefix`, allows changing the prefix for the current session.
- Dictionary keybindings are now loaded into the main prefix map via `eval-after-load`, improving modularity.
|
|
The validation for dictionary replacements was overly restrictive. It used
the "\\W" regexp class, which disallows any character that is not a
word constituent. This could prevent legitimate replacements.
The check is now more specific, using the "[[:punct:]]" character class
to only forbid punctuation marks. This aligns better with the intended
behavior. The user
error message has been updated accordingly.
|
|
- In `greader-dict.el`:
- Remove a `goto-char` call in `greader-dict-substitute-words`,
which was a leftover from a previous refactoring.
- In `greader-dict-add-interactive`, prevent users from adding a
replacement that contains non-word characters. This avoids
unexpected behavior with text-to-speech engines.
- Improve the docstrings for `greader-dict-add` and
`greader-dict-filter-add` to better explain their behavior and
limitations, especially regarding input validation and the use of
special characters.
|
|
|
|
|
|
Without this `(require 'greader)`, the Guix package manager cannot
build the package, as noted here:
<https://codeberg.org/guix/guix/pulls/1360#issuecomment-5901343>
|
|
|
|
Fixed changing language, the change now reflects immediately.
Also the function `greader-dict-info' updated to count even defined
filters.
|
|
indenting the body as a function.
|
|
Now greader-dict.el uses this macro for operate with temp buffers.
|
|
|
|
Now it manages correctly an empty word.
|
|
permit enabling or disabling the new feature.
|
|
|
|
only when the replacement parameter contains a word.
|
|
Now this function handles the case in which there are two or more
instances of the match.
For example:
If you want to substitute the word "einstein" defining a match "ein"
there are two matches in the same word.
|
|
and added as word in the dictionary. In this way i hope that the performance of substitution will be slightly improved.
|
|
handle correctly things which have properties.
|
|
Documentation of command `greader-dict-add-entry' improved.
|
|
Now it works with "\" correctly.
|
|
Now filters support multiple lines, them will be transformed in a
regexp that don't conflict with the routine that reads the dictionary.
More precisely, a "\n" will be replaced with "[[:space:]]" when it is
saved in the database.
furthermore, now filters can be replaced with an empty string.
|
|
|
|
|
|
Now when this function is called without a prefix, it proposes only
matches classified as words for completion.
|
|
|
|
|
|
Function `greader-dict-add-entry fixed.
|
|
- Function `greader-dict--get-key-from-word simplified.
- other minor fixes.
|
|
|
|
Minor fixes.
|
|
|
|
|