Puvodni over-engineered pristup (require + after! + condition-case) nebyl
potreba. :after org + global-org-modern-mode v :config je spravny Doom idiom.
Lze revertovat timto jednim commitem pokud org-modern dela problemy.
- org-modern: revert na global-org-modern-mode (puvodni coder verze fungovala)
guard approach zpusoboval bily/neformatovany text
- olivetti: pridano zpet na org+markdown+text-mode-hook s buffer-file-name guardem
(export temp buffery maji buffer-file-name=nil, olivetti se tam nespusti)
- org-modern: pouzit :hook s pojmenovanou funkci my/org-modern-maybe
+ after! blok ktery aplikuje org-modern i na uz otevrene buffery (inbox.org)
- org-fragtog: same pattern, pojmenovana fn my/org-fragtog-maybe
- org-super-agenda: odebrana skupina Brzy (before +3d nespolehliva v quoted list),
org-super-agenda-mode presunuto do after! bloku (jistejsi load-order)
Emacs 31 changed behavior of replace-regexp-in-string with lambda replacements
containing backslashes: 'Invalid use of backslash in replacement text' error.
Fix: use with-temp-buffer + re-search-forward + replace-match (literal t t).
replace-match with LITERAL=t never processes backslash sequences.
Also fixes \end{tabular} → \end{tabularx} regex to not match existing tabularx.
document.org template defines Y column type (RaggedRight + auto-width X).
Filter now computes proper column spec:
- 1 col → Y
- N cols → l + (N-1)*Y (first col natural-width, rest auto-width)
Also handles tabularx{colspec} → tabularx{\linewidth}{lYYY} (missing width fix).
Works with ltablex (loaded by template) which makes tabularx also support page breaks.
Root cause of \begin{tabularx}{lll} error: org-latex in this version does not
add \linewidth for tabularx environment, generating invalid LaTeX.
Fix: org-export-filter-table-functions filter that transforms rendered output:
- \begin{tabular}{spec} → \begin{tabularx}{\linewidth}{spec}
- \begin{tabularx}{spec} → \begin{tabularx}{\linewidth}{spec} (missing width fix)
- \end{tabular} → \end{tabularx}
No buffer modification → no recursion, works on Emacs 31.
Belt+suspenders registration: with-eval-after-load 'ox-latex + explicit
require+add-to-list in org-export-before-processing-hook ensures the filter
is always registered before the export transcoder runs.
Root cause of Emacs 31 recursion: insert in org-export-before-processing-hook
triggers hooks that inhibit-modification-hooks does not suppress on Emacs 31
(window management, org-fold text properties, etc.). The old Mac (older Emacs)
was not affected.
Fix: setq-local org-latex-default-table-environment in the hook.
No buffer content modification → no hook chains → no recursion possible.
org-latex.el natively handles tabularx by adding \linewidth width argument.
tabularx added to org-latex-packages-alist.
Restore the hook-based approach from acb3875 (original working version) + the
inhibit-modification-hooks fix from 457b9d3 that made it work on Emacs 31.
457b9d3 confirmed working by Martin (PDF exported) — only issue was the syntax
warning from the stray paren. This commit has correct paren balance.
Also keep pdf-tools config and corfu-terminal Emacs 31 guard from 98b53cb.
org-export-filter-table-functions timing was unreliable (after! ox-latex
runs too late or filter not called for all table types). Around advice on
org-latex-table is called directly during transcoding, guaranteed to run.
Also switched to with-eval-after-load for more predictable load timing.
The insert call in my/org-auto-tabularx triggered buffer-change hooks (e.g.
org-element-cache) during LaTeX export, causing infinite recursion and
'max-lisp-eval-depth exceeded'. HTML export was unaffected (hook only runs
for latex backend). Fix: wrap body in (let ((inhibit-modification-hooks t))).
- org-file-apps: use 'open %s' for PDF on darwin → async launch, no beachball
- org-latex-pdf-process: explicit latexmk -f -interaction=nonstopmode
(belt+suspenders; Doom module sets this but not always loaded early enough)
pixel-scroll-precision-mode (from previous commit) breaks scrolling on
NS/Cocoa builds: it rebinds [wheel-up/down] to precision handlers that
do not work with the NS event system, resulting in zero scroll response.
Fix: remove pixel-scroll-precision-mode, use standard mwheel.el:
- require mwheel explicitly (Doom may not load it early enough)
- 3 lines/tick, shift=1, meta=0, ctrl=text-scale
- mouse-wheel-progressive-speed nil (constant speed, no acceleration)
- mouse-wheel-tilt-scroll t (horizontal two-finger scroll)
- explicitly bind [wheel-up/down] to mwheel-scroll (prevents Doom
remapping from silently eating scroll events)
macOS NS/Cocoa Emacs generates pixel-level scroll events from trackpad
and Magic Mouse. Without pixel-scroll-precision-mode, these events are
handled as line-based scrolling, resulting in jerky or broken scroll
behavior.
Changes:
- Enable pixel-scroll-precision-mode (Emacs 29+) in GUI mode
- Set pixel-scroll-precision-large-scroll-height to 40.0 (prevents
trackpad fling from being interpolated frame-by-frame)
- Enable momentum scrolling (trackpad inertia from macOS)
- Keep line-based mouse-wheel-scroll-amount as fallback for physical
scroll wheels
- mouse-autoselect-window nil: mouse movement no longer switches
active window (was the main cause of apparent cursor jumping)
- focus-follows-mouse nil: same — no focus change on hover
- mouse clicks still disabled ([mouse-1..3] → #'ignore)
- scroll wheel explicitly configured: 3 lines/tick, no acceleration,
no progressive speed (mouse-wheel-scroll-amount)
my/smart-paste bound to s-v (cmd+v) in org-mode and markdown-mode:
- clipboard has image → my/paste-image-from-clipboard
- clipboard has text → normal yank
my/paste-image-from-clipboard:
- saves to attachments/ relative to current file
- filename: image-YYYYMMDD-HHMMSS.png
- org-mode: [[./attachments/image-....png]]
- markdown-mode: 
- creates attachments/ dir if missing
Requires: brew install pngpaste
my/ement-maybe-restore now:
- Loads sessions file manually (ement--load-sessions) before connecting
- Calls ement--reconnect directly on each loaded session — bypasses all
interactive prompts in ement-connect (homeserver discovery, read-passwd)
- Fallback to ement-connect with explicit :homeserver if --reconnect absent
- condition-case wrapper — startup errors are silent, never block Emacs
my/ement-open: use my/ement-maybe-restore (instead of ement-connect
directly) for the 'sessions file exists' branch.
ement checks ement-save-sessions during its own init to register
kill-emacs-hook. Setting it inside after! was too late — the hook
wasn't added, so sessions were never saved on Emacs exit.
Also set ement-sessions-file explicitly to doom-private-dir to avoid
no-littering path redirection surprises.
my/ement-open now handles 3 cases:
1. Already connected -> ement-list-rooms immediately
2. Sessions file exists -> ement-connect (no credentials), then
open rooms via ement-after-initial-sync-hook
3. No saved session -> call-interactively ement-connect, then rooms
my/ement-open-after-sync: self-removing hook that opens room list
after initial sync completes (regardless of how connect was triggered).
Startup auto-connect unchanged (doom-after-init-hook).
Functions defined inside (after! ement ...) are not registered as
interactive commands by Doom. Move my/ement-maybe-restore and
my/ement-open to top level.
Also move add-hook from inside after! to top level (after-init-hook
fires before lazy packages load — use doom-after-init-hook instead).
- my/ement-maybe-restore: restores saved session on after-init-hook,
no credentials prompt (requires one manual login first)
- my/ement-open: SPC o M o — connects if needed, then ement-list-rooms
- Remove SPC o M s (ement-sync is internal, manual call causes double-loop)
- Update quick reference comments
1. my/org-agenda-goto-task-name: replace face-based detection with
regexp-opt over org-todo-keywords. Works for all keywords
(TODO, NEXT, WAIT, DONE, CANCELLED, ...), not just TODO/DONE.
Added helper my/org-agenda-all-keywords.
2. Disable mouse clicks in GUI Emacs (Fix C in macOS GUI section):
global-set-key [mouse-*] to #'ignore, mouse-highlight nil.
Prevents accidental cursor movement when touching trackpad.
Doom mu4e module binds SPC o m directly to #'mu4e (non-prefix).
Collision prevented ement keybindings from loading.
Renamed Matrix prefix to SPC o M (uppercase).
Compilation error: EmacsView does not declare NSAccessibility conformance
so accessibilityConvertScreenRect: is not visible to the compiler.
Replaced with manual coordinate conversion:
primaryH = NSScreen.screens.first.frame.height
cgRect.origin.y = primaryH - cgRect.origin.y - cgRect.size.height
Root cause found via research pipeline:
NSAccessibility notifications alone are insufficient for custom NSView.
macOS Zoom 'Follow keyboard focus' requires UAZoomChangeFocus() from
HIServices/UniversalAccess.h — same as iTerm2 and Chromium.
Squashed into single clean patch. 159 insertions, 2 files.
macOS Zoom is event-driven -- it only queries AXBoundsForRange after
receiving NSAccessibilitySelectedTextChangedNotification. Previous
version implemented the bounds methods but never posted notifications,
so Zoom never triggered a cursor position query.
Added:
- NSAccessibilityPostNotification(SelectedTextChanged) in ns_draw_window_cursor
- NSAccessibilityPostNotification(FocusedUIElementChanged) in windowDidBecomeKey
- accessibilityAttributeNames + accessibilityAttributeValue: for
NSAccessibilitySelectedTextRangeAttribute -> returns {0,0}
Old parameterized attribute API alone insufficient — macOS Zoom prefers
the new NSAccessibilityProtocol method accessibilityBoundsForRange:.
Also adds isAccessibilityElement returning YES.
Both APIs now implemented for compatibility across macOS versions.