Inital 31.1 changes
This commit is contained in:
@@ -1,311 +0,0 @@
|
|||||||
;;; corfu-terminal-popupinfo.el --- corfu-popupinfo support in the terminal -*- lexical-binding: t -*-
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
;; To make use of this file, simply `require' it, and then enable
|
|
||||||
;; `corfu-terminal-popupinfo-mode', which is a global mode. Note that
|
|
||||||
;; `corfu-terminal-mode' MUST be loaded and enabled for this to work.
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
(require 'popon)
|
|
||||||
(require 'corfu-terminal)
|
|
||||||
(require 'corfu-popupinfo)
|
|
||||||
(require 'cl-lib)
|
|
||||||
|
|
||||||
(defvar ctp--popon nil
|
|
||||||
"The current popon, or nil if there is none.")
|
|
||||||
|
|
||||||
(defvar ctp--buffer nil
|
|
||||||
"The buffer holding the current candidate's documentation.")
|
|
||||||
|
|
||||||
(defun ctp--get-buffer ()
|
|
||||||
"Create or return `ctp--buffer'."
|
|
||||||
(unless (and (bufferp ctp--buffer) (buffer-live-p ctp--buffer))
|
|
||||||
(setq ctp--buffer (generate-new-buffer " *corfu-terminal-popupinfo*" t)))
|
|
||||||
ctp--buffer)
|
|
||||||
|
|
||||||
(defun ctp--visible-p ()
|
|
||||||
"Return non-nil if the terminal popup window is visible."
|
|
||||||
(popon-live-p ctp--popon))
|
|
||||||
|
|
||||||
(defun ctp--corfu-popupinfo--visible-p-advice (oldfun &optional frame)
|
|
||||||
"Advice for `corfu-popupinfo--visible-p'.
|
|
||||||
If FRAME is nil, this will return `ctp--visible-p'. If
|
|
||||||
FRAME is `corfu--frame', this will return weather the `corfu-terminal--popon' is
|
|
||||||
live or not.
|
|
||||||
|
|
||||||
As this is :around advice, OLDFUN is the real (advised) function to call."
|
|
||||||
(cond
|
|
||||||
((and (not frame) (ctp--visible-p)))
|
|
||||||
((and (eq frame corfu--frame) (popon-live-p corfu-terminal--popon)))
|
|
||||||
((funcall oldfun frame))))
|
|
||||||
|
|
||||||
(defun ctp--close ()
|
|
||||||
"Close the popon."
|
|
||||||
(popon-kill ctp--popon)
|
|
||||||
(setq ctp--popon nil))
|
|
||||||
|
|
||||||
(defalias 'ctp--corfu-popupinfo--hide-advice 'ctp--close
|
|
||||||
"Advice for `corfu-popupinfo--hide' that works in the terminal.")
|
|
||||||
|
|
||||||
(defun ctp--load-content (candidate buffer)
|
|
||||||
"Load the documentation for CANDIDATE into BUFFER."
|
|
||||||
(when-let* ((content (funcall corfu-popupinfo--function candidate)))
|
|
||||||
;; A bunch of this comes straight from `corfu-popupinfo--show'
|
|
||||||
(with-current-buffer buffer
|
|
||||||
(dolist (var corfu-popupinfo--buffer-parameters)
|
|
||||||
(set (make-local-variable (car var)) (cdr var)))
|
|
||||||
(with-silent-modifications
|
|
||||||
(erase-buffer)
|
|
||||||
(insert content)
|
|
||||||
;; popon.el requires that each line be of the same width. As we are in
|
|
||||||
;; the terminal, we assume that each character is the same width (and
|
|
||||||
;; we can't do anything, or even know, if this is not the case). Thus,
|
|
||||||
;; we run over the buffer to pad out each line to the width of the
|
|
||||||
;; longest line.
|
|
||||||
(goto-char (point-min))
|
|
||||||
(let ((wrap-p (and (not truncate-lines) word-wrap))
|
|
||||||
(longest-line 0))
|
|
||||||
(cl-block nil
|
|
||||||
(while (not (eobp))
|
|
||||||
(let ((len (- (pos-eol) (pos-bol))))
|
|
||||||
(when (> len longest-line)
|
|
||||||
(setq longest-line len))
|
|
||||||
(when (and wrap-p (> longest-line corfu-popupinfo-max-width))
|
|
||||||
(setq longest-line corfu-popupinfo-max-width)
|
|
||||||
(cl-return)))
|
|
||||||
(forward-line)))
|
|
||||||
(setq-local fill-column longest-line)
|
|
||||||
(when wrap-p
|
|
||||||
(fill-region (point-min) (point-max)))
|
|
||||||
(goto-char (point-min))
|
|
||||||
(while (not (eobp))
|
|
||||||
(end-of-line)
|
|
||||||
(let ((len (- (point) (pos-bol))))
|
|
||||||
(when (< len longest-line)
|
|
||||||
(insert (make-string (- longest-line len) ? ))))
|
|
||||||
(forward-line))))
|
|
||||||
(goto-char (point-min))
|
|
||||||
(put-text-property (point-min) (point-max) 'face 'corfu-popupinfo)
|
|
||||||
(when-let* ((m (memq 'corfu-default (alist-get 'default face-remapping-alist))))
|
|
||||||
(setcar m 'corfu-popupinfo)))
|
|
||||||
;; We succeeded in loading the data
|
|
||||||
t))
|
|
||||||
|
|
||||||
(defun ctp--popon-position (buffer)
|
|
||||||
"Find a good position to open the popon for BUFFER's content.
|
|
||||||
Return a list of the position, the max line length that can be shown, and the
|
|
||||||
max height that can be shown. Each line of BUFFER _MUST_ be the same lenght."
|
|
||||||
(when-let* ((point-posn (posn-at-point))
|
|
||||||
(point-x (car (posn-x-y point-posn)))
|
|
||||||
(point-y (cdr (posn-x-y point-posn))))
|
|
||||||
(with-current-buffer buffer
|
|
||||||
(when-let* ((completion-pos (popon-position corfu-terminal--popon))
|
|
||||||
(completion-size (popon-size corfu-terminal--popon))
|
|
||||||
(comp-x (car completion-pos))
|
|
||||||
(comp-y (cdr completion-pos))
|
|
||||||
(comp-w (car completion-size))
|
|
||||||
(comp-h (cdr completion-size))
|
|
||||||
(win-w (window-max-chars-per-line))
|
|
||||||
(win-h (window-body-height))
|
|
||||||
(line-len (- (pos-eol) (pos-bol)))
|
|
||||||
(num-lines (count-lines (point-min) (point-max))))
|
|
||||||
(let* ((align 'row)
|
|
||||||
(width (min line-len corfu-popupinfo-max-width))
|
|
||||||
(pop-x (cond
|
|
||||||
((<= (+ comp-x comp-w width) win-w)
|
|
||||||
(+ comp-x comp-w))
|
|
||||||
((>= (- comp-x width) 0)
|
|
||||||
(- comp-x width))
|
|
||||||
((<= (+ comp-x width) win-w)
|
|
||||||
(setq align 'col)
|
|
||||||
comp-x)
|
|
||||||
((>= (- win-w width) 0)
|
|
||||||
(setq align 'col)
|
|
||||||
(- win-w width))
|
|
||||||
(t
|
|
||||||
(setq align 'col
|
|
||||||
width win-w)
|
|
||||||
0)))
|
|
||||||
(height (min num-lines corfu-popupinfo-max-height))
|
|
||||||
(pop-y (cl-case align
|
|
||||||
(row (if (<= (+ comp-y height) win-h)
|
|
||||||
comp-y
|
|
||||||
(max 0 (- win-h height))))
|
|
||||||
(col (cond
|
|
||||||
((<= (+ comp-y comp-h height)
|
|
||||||
(- win-h scroll-margin))
|
|
||||||
(+ comp-y comp-h))
|
|
||||||
;; If the completion dialog is above the point
|
|
||||||
((and (< comp-y point-y)
|
|
||||||
(>= (- comp-y height) 0))
|
|
||||||
(- comp-y height))
|
|
||||||
;; Emacs seems to hide the current text if this
|
|
||||||
;; number is 1 (I think it's too close to two
|
|
||||||
;; overlays)
|
|
||||||
((>= (- comp-y height 2) 0)
|
|
||||||
(- comp-y height 2))
|
|
||||||
(t (+ comp-y comp-h)))))))
|
|
||||||
(list (cons pop-x pop-y) width height))))))
|
|
||||||
|
|
||||||
(defun ctp--extract-content (buffer width height)
|
|
||||||
"Extract the content from BUFFER for a popon.
|
|
||||||
The content extracted is for a popon of size WIDTH by HEIGHT."
|
|
||||||
(let (start end)
|
|
||||||
(with-current-buffer buffer
|
|
||||||
;; we assume that we are scrolled to the start of the region we care about
|
|
||||||
(save-excursion
|
|
||||||
(let ((rem-lines (count-lines (point) (point-max))))
|
|
||||||
(when (< rem-lines height)
|
|
||||||
(forward-line (- rem-lines height))))
|
|
||||||
(setq start (point)
|
|
||||||
end (pos-eol height))))
|
|
||||||
(with-temp-buffer
|
|
||||||
(insert-buffer-substring buffer start end)
|
|
||||||
(goto-char (point-min))
|
|
||||||
(cl-loop repeat height
|
|
||||||
until (eobp) do
|
|
||||||
(let ((len (- (pos-eol) (pos-bol))))
|
|
||||||
(when (> len width)
|
|
||||||
(delete-region (+ (pos-bol) width) (pos-eol))))
|
|
||||||
(forward-line))
|
|
||||||
;; "delete" the rest of the lines
|
|
||||||
(narrow-to-region (point-min) (point))
|
|
||||||
(buffer-string))))
|
|
||||||
|
|
||||||
(defun ctp--display-buffer (buffer)
|
|
||||||
"Display or redisplay BUFFER in a popon."
|
|
||||||
(let ((inhibit-redisplay t))
|
|
||||||
(cl-destructuring-bind (&optional pos width height)
|
|
||||||
(ctp--popon-position buffer)
|
|
||||||
(popon-kill ctp--popon)
|
|
||||||
(when-let* ((pos)
|
|
||||||
(content (ctp--extract-content buffer width height)))
|
|
||||||
(setq ctp--popon
|
|
||||||
;; appear behind the auto-complete window, in case something
|
|
||||||
;; happens
|
|
||||||
(popon-create content pos nil nil 100))))))
|
|
||||||
|
|
||||||
(defun ctp--corfu-popupinfo--show-advice (oldfun candidate)
|
|
||||||
"Advice for `corfu-popupinfo--show' that works in the terminal.
|
|
||||||
CANDIDATE is the same as for `corfu-popupinfo--show'. As this is meant to be
|
|
||||||
:around advice, OLDFUN is assumed to be the real (advised) function."
|
|
||||||
(if (display-graphic-p)
|
|
||||||
(progn
|
|
||||||
(popon-kill ctp--popon)
|
|
||||||
(funcall oldfun candidate))
|
|
||||||
(when corfu-popupinfo--timer
|
|
||||||
(cancel-timer corfu-popupinfo--timer)
|
|
||||||
(setq corfu-popupinfo--timer nil))
|
|
||||||
(when (and (frame-live-p corfu-popupinfo--frame)
|
|
||||||
(frame-visible-p corfu-popupinfo--frame))
|
|
||||||
(corfu--hide-frame corfu-popupinfo--frame))
|
|
||||||
(when (or (not (ctp--visible-p))
|
|
||||||
(not (equal-including-properties
|
|
||||||
candidate corfu-popupinfo--candidate)))
|
|
||||||
(let ((buf (ctp--get-buffer)))
|
|
||||||
(if (ctp--load-content candidate buf)
|
|
||||||
(progn
|
|
||||||
(ctp--display-buffer buf)
|
|
||||||
(setq corfu-popupinfo--candidate candidate
|
|
||||||
corfu-popupinfo--toggle t))
|
|
||||||
(corfu-popupinfo--hide))))))
|
|
||||||
|
|
||||||
(defun ctp--move-away-from-eob ()
|
|
||||||
"Ensure the point isn't too close to the end of the buffer."
|
|
||||||
(if-let* ((total-lines (count-lines (point-min) (point-max)))
|
|
||||||
((> total-lines corfu-popupinfo-max-height))
|
|
||||||
(rem-lines (count-lines (point) (point-max)))
|
|
||||||
((< rem-lines corfu-popupinfo-max-height)))
|
|
||||||
(forward-line (- (- corfu-popupinfo-max-height rem-lines)))))
|
|
||||||
|
|
||||||
(defun ctp--corfu-popupinfo-scroll-up-advice
|
|
||||||
(oldfun &optional n)
|
|
||||||
"Advice for `corfu-popupinfo-scroll-up'.
|
|
||||||
N is the number of lines. As this is :around advice, OLDFUN is the real
|
|
||||||
\(advised) function."
|
|
||||||
(if (ctp--visible-p)
|
|
||||||
(let ((buf (ctp--get-buffer)))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(forward-line n)
|
|
||||||
(beginning-of-line)
|
|
||||||
(ctp--move-away-from-eob))
|
|
||||||
(ctp--display-buffer buf))
|
|
||||||
(funcall oldfun n)))
|
|
||||||
|
|
||||||
(defun ctp--corfu-popupinfo-end-advice (oldfun &optional n)
|
|
||||||
"Advice for `corfu-popupinfo-end'.
|
|
||||||
N is the same as for `corfu-popupinfo-end'. As this is :around advice, OLDFUN
|
|
||||||
is the real (advised) function."
|
|
||||||
(if (ctp--visible-p)
|
|
||||||
(let ((buf (ctp--get-buffer)))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(let ((size (- (point-max) (point-min))))
|
|
||||||
(goto-char (if n
|
|
||||||
(- (point-max) (/ (* size n) 10))
|
|
||||||
(point-max))))
|
|
||||||
(beginning-of-line)
|
|
||||||
(ctp--move-away-from-eob))
|
|
||||||
(ctp--display-buffer buf))
|
|
||||||
(funcall oldfun n)))
|
|
||||||
|
|
||||||
(defun ctp--corfu--popup-hide-advice ()
|
|
||||||
":after advice for `corfu--popup-hide'."
|
|
||||||
(unless completion-in-region-mode
|
|
||||||
(ctp--close)))
|
|
||||||
|
|
||||||
(defun ctp--enable ()
|
|
||||||
"Enable corfu terminal popupinfo by advising some corfu functions."
|
|
||||||
(advice-add 'corfu-popupinfo--visible-p :around
|
|
||||||
'ctp--corfu-popupinfo--visible-p-advice)
|
|
||||||
(advice-add 'corfu-popupinfo--hide :after
|
|
||||||
'ctp--corfu-popupinfo--hide-advice)
|
|
||||||
(advice-add 'corfu-popupinfo--show :around
|
|
||||||
'ctp--corfu-popupinfo--show-advice)
|
|
||||||
(advice-add 'corfu-popupinfo-scroll-up :around
|
|
||||||
'ctp--corfu-popupinfo-scroll-up-advice)
|
|
||||||
(advice-add 'corfu-popupinfo-end :around
|
|
||||||
'ctp--corfu-popupinfo-end-advice)
|
|
||||||
(advice-add 'corfu--popup-hide :after
|
|
||||||
'ctp--corfu--popup-hide-advice))
|
|
||||||
|
|
||||||
(defun ctp--disable ()
|
|
||||||
"Disable corfu terminal popupinfo by remove advice added by `ctp--enable'."
|
|
||||||
(ctp--close)
|
|
||||||
(advice-remove 'corfu-popupinfo--visible-p
|
|
||||||
'ctp--corfu-popupinfo--visible-p-advice)
|
|
||||||
(advice-remove 'corfu-popupinfo--hide
|
|
||||||
'ctp--corfu-popupinfo--hide-advice)
|
|
||||||
(advice-remove 'corfu-popupinfo--show
|
|
||||||
'ctp--corfu-popupinfo--show-advice)
|
|
||||||
(advice-remove 'corfu-popupinfo-scroll-up
|
|
||||||
'ctp--corfu-popupinfo-scroll-up-advice)
|
|
||||||
(advice-remove 'corfu-popupinfo-end
|
|
||||||
'ctp--corfu-popupinfo-end-advice)
|
|
||||||
(advice-remove 'corfu--popup-hide
|
|
||||||
'ctp--corfu--popup-hide-advice))
|
|
||||||
|
|
||||||
(defun ctp--corfu-terminal-mode-hook ()
|
|
||||||
"Hook run from `corfu-terminal-mode-hook'."
|
|
||||||
(if (and corfu-terminal-mode
|
|
||||||
(bound-and-true-p corfu-terminal-popupinfo-mode))
|
|
||||||
(ctp--enable)
|
|
||||||
(ctp--disable)))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(define-minor-mode corfu-terminal-popupinfo-mode
|
|
||||||
"Minor mode shows the `corfu-popupinfo-mode' popup in the terminal.
|
|
||||||
Note that even with this enabled, you still need to enable the actual popup
|
|
||||||
using `corfu-popupinfo-toggle'. Also, this does not do anything if
|
|
||||||
`corfu-terminal-mode' is not enabled."
|
|
||||||
:global t
|
|
||||||
:group 'corfu-terminal-popupinfo
|
|
||||||
(if corfu-terminal-popupinfo-mode
|
|
||||||
(progn
|
|
||||||
(add-hook 'corfu-terminal-mode-hook 'ctp--corfu-terminal-mode-hook)
|
|
||||||
(when corfu-terminal-mode
|
|
||||||
(ctp--enable)))
|
|
||||||
(remove-hook 'corfu-terminal-mode-hook 'ctp--corfu-terminal-mode-hook)
|
|
||||||
(ctp--disable)))
|
|
||||||
|
|
||||||
(provide 'corfu-terminal-popupinfo)
|
|
||||||
;;; corfu-terminal-popupinfo.el ends here
|
|
||||||
@@ -54,7 +54,7 @@ These should end with a slash (/) if their are a directory."
|
|||||||
ARGS are passed uncaged to Firejail and should include the proper debug command."
|
ARGS are passed uncaged to Firejail and should include the proper debug command."
|
||||||
(ignore-error file-missing
|
(ignore-error file-missing
|
||||||
(mapcan (lambda (line)
|
(mapcan (lambda (line)
|
||||||
(when (string-match (rx "- " (group (+ any)) eol) line)
|
(when (string-match (rx "- " (group (+ not-newline)) eol) line)
|
||||||
(list (match-string 1 line))))
|
(list (match-string 1 line))))
|
||||||
(apply 'process-lines firejail-executable args))))
|
(apply 'process-lines firejail-executable args))))
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ languages supported by this interpreter."))
|
|||||||
(defun inf-cc--remove-surrounding-parens (str)
|
(defun inf-cc--remove-surrounding-parens (str)
|
||||||
"Remove surrounding parenthesis from STR."
|
"Remove surrounding parenthesis from STR."
|
||||||
(if (string-match (rx bos (* (syntax whitespace)) "("
|
(if (string-match (rx bos (* (syntax whitespace)) "("
|
||||||
(group (* any))
|
(group (* not-newline))
|
||||||
")" (* (syntax whitespace)) eos)
|
")" (* (syntax whitespace)) eos)
|
||||||
str)
|
str)
|
||||||
(match-string 1 str)
|
(match-string 1 str)
|
||||||
|
|||||||
+2
-2
@@ -90,7 +90,7 @@ PROC and STR are described in `set-process-filter'."
|
|||||||
(concat (string-join errors "\n") "\n")))))
|
(concat (string-join errors "\n") "\n")))))
|
||||||
(process-send-string proc "y\n")
|
(process-send-string proc "y\n")
|
||||||
(process-send-string proc "n\n")))
|
(process-send-string proc "n\n")))
|
||||||
((string-match (rx bos "Error: " (group (+ any)) eol) line)
|
((string-match (rx bos "Error: " (group (+ not-newline)) eol) line)
|
||||||
(push (match-string 1 line) errors)))))
|
(push (match-string 1 line) errors)))))
|
||||||
(with-editor-process-filter proc str t))
|
(with-editor-process-filter proc str t))
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
|
|||||||
(when (and (message-point-in-header-p)
|
(when (and (message-point-in-header-p)
|
||||||
(message-beginning-of-header t))
|
(message-beginning-of-header t))
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(when (and (looking-at (rx bol (group (+? any)) ":" (? " ")))
|
(when (and (looking-at (rx bol (group (+? not-newline)) ":" (? " ")))
|
||||||
(funcall (or testfn 'equal) (match-string 1) name))
|
(funcall (or testfn 'equal) (match-string 1) name))
|
||||||
(match-end 0)))))
|
(match-end 0)))))
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -272,7 +272,7 @@ FOUND is the hash table in which to put the entries."
|
|||||||
while dir
|
while dir
|
||||||
when (file-directory-p dir) do
|
when (file-directory-p dir) do
|
||||||
(let ((files (directory-files dir t)))
|
(let ((files (directory-files dir t)))
|
||||||
(if (cl-member-if (lambda (file)
|
(if (member-if (lambda (file)
|
||||||
(latex-help--is-marker-file file root))
|
(latex-help--is-marker-file file root))
|
||||||
files)
|
files)
|
||||||
;; dir is an entry
|
;; dir is an entry
|
||||||
@@ -295,7 +295,7 @@ FOUND is the hash table in which to put the entries."
|
|||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(forward-line 2)
|
(forward-line 2)
|
||||||
(cl-loop while (re-search-forward (rx bol (+ " ") "active" "\t"
|
(cl-loop while (re-search-forward (rx bol (+ " ") "active" "\t"
|
||||||
(group (+ any)) eol) nil t)
|
(group (+ not-newline)) eol) nil t)
|
||||||
collect (match-string 1))))
|
collect (match-string 1))))
|
||||||
|
|
||||||
(defun latex-help--texdoc-config-file-entries (file found)
|
(defun latex-help--texdoc-config-file-entries (file found)
|
||||||
@@ -359,7 +359,7 @@ prompting with `completing-read'."
|
|||||||
"\t"
|
"\t"
|
||||||
(? (+ (not "\t")))
|
(? (+ (not "\t")))
|
||||||
"\t"
|
"\t"
|
||||||
(group (* any))))
|
(group (* not-newline))))
|
||||||
nil t)
|
nil t)
|
||||||
for file = (match-string 1)
|
for file = (match-string 1)
|
||||||
for desc = (match-string 2)
|
for desc = (match-string 2)
|
||||||
@@ -424,8 +424,8 @@ This is done by parsing the index for `latex-help-info-manual'."
|
|||||||
(group (or
|
(group (or
|
||||||
","
|
","
|
||||||
(+ (not (any " " "{" ",")))))
|
(+ (not (any " " "{" ",")))))
|
||||||
(*? any) ":" (+ " ")
|
(*? not-newline) ":" (+ " ")
|
||||||
(group (+? any)) ".")))))
|
(group (+? not-newline)) ".")))))
|
||||||
(push (list "(SPACE)" "\\(SPACE)") found)
|
(push (list "(SPACE)" "\\(SPACE)") found)
|
||||||
(when-let* ((entry (assoc "(...\\)" found)))
|
(when-let* ((entry (assoc "(...\\)" found)))
|
||||||
(setq found (assoc-delete-all "(...\\)" found))
|
(setq found (assoc-delete-all "(...\\)" found))
|
||||||
@@ -441,20 +441,20 @@ This is done by parsing the index for `latex-help-info-manual'."
|
|||||||
"Discover LaTeX packages.
|
"Discover LaTeX packages.
|
||||||
This is done by parsing the index for `latex-help-info-manual'."
|
This is done by parsing the index for `latex-help-info-manual'."
|
||||||
(latex-help--run-index-search (rx (and bol "* package, "
|
(latex-help--run-index-search (rx (and bol "* package, "
|
||||||
(group (+? any))
|
(group (+? not-newline))
|
||||||
(any " " ":")
|
(any " " ":")
|
||||||
(+? any) (+ " ")
|
(+? not-newline) (+ " ")
|
||||||
(group (+? any))
|
(group (+? not-newline))
|
||||||
"."))))
|
"."))))
|
||||||
|
|
||||||
(defun latex-help--discover-environments ()
|
(defun latex-help--discover-environments ()
|
||||||
"Discover LaTeX environments.
|
"Discover LaTeX environments.
|
||||||
This is done by parsing the index for `latex-help-info-manual'."
|
This is done by parsing the index for `latex-help-info-manual'."
|
||||||
(latex-help--run-index-search (rx (and bol "* environment, "
|
(latex-help--run-index-search (rx (and bol "* environment, "
|
||||||
(group (+? any))
|
(group (+? not-newline))
|
||||||
(any " " ":" "-")
|
(any " " ":" "-")
|
||||||
(+? any) (+ " ")
|
(+? not-newline) (+ " ")
|
||||||
(group (+? any))
|
(group (+? not-newline))
|
||||||
"."))))
|
"."))))
|
||||||
|
|
||||||
(defun latex-help--discover-classes ()
|
(defun latex-help--discover-classes ()
|
||||||
@@ -589,7 +589,7 @@ from the texdoc cache."
|
|||||||
(car prompts)))))
|
(car prompts)))))
|
||||||
(when (string-match (rx bos "(" (group (+ (any (?a . ?z))
|
(when (string-match (rx bos "(" (group (+ (any (?a . ?z))
|
||||||
(any (?A . ?Z))))
|
(any (?A . ?Z))))
|
||||||
") " (group (* any)))
|
") " (group (* not-newline)))
|
||||||
selected)
|
selected)
|
||||||
(if (equal (match-string 1 selected) "Info")
|
(if (equal (match-string 1 selected) "Info")
|
||||||
(cons (assoc (match-string 2 selected) (cdr info-entry)) 'info)
|
(cons (assoc (match-string 2 selected) (cdr info-entry)) 'info)
|
||||||
@@ -670,7 +670,7 @@ Prompt the user for an info topic or texdoc file, then open that thing."
|
|||||||
(if (string-prefix-p "(Texdoc) " ans)
|
(if (string-prefix-p "(Texdoc) " ans)
|
||||||
(latex-help-texdoc (seq-subseq ans (length "(Texdoc) ")))
|
(latex-help-texdoc (seq-subseq ans (length "(Texdoc) ")))
|
||||||
(string-match (rx "(Info) " (group (+ (not " ")))
|
(string-match (rx "(Info) " (group (+ (not " ")))
|
||||||
" - " (group (+ any)))
|
" - " (group (+ not-newline)))
|
||||||
ans)
|
ans)
|
||||||
(when-let* ((thing (match-string 2 ans))
|
(when-let* ((thing (match-string 2 ans))
|
||||||
(type (intern (downcase (match-string 1 ans))))
|
(type (intern (downcase (match-string 1 ans))))
|
||||||
|
|||||||
@@ -76,16 +76,16 @@ about this change."
|
|||||||
(when (and
|
(when (and
|
||||||
(re-search-forward (rx bol (literal mail-header-separator) eol)
|
(re-search-forward (rx bol (literal mail-header-separator) eol)
|
||||||
nil t)
|
nil t)
|
||||||
(re-search-forward (rx "<#multipart" (* any) ">")
|
(re-search-forward (rx "<#multipart" (* not-newline) ">")
|
||||||
nil t)
|
nil t)
|
||||||
(re-search-forward (rx "<#part " (* any)
|
(re-search-forward (rx "<#part " (* not-newline)
|
||||||
"type=" (literal type) (* any) ">")
|
"type=" (literal type) (* not-newline) ">")
|
||||||
nil t))
|
nil t))
|
||||||
(let ((start (match-end 0))
|
(let ((start (match-end 0))
|
||||||
(end (point-max)))
|
(end (point-max)))
|
||||||
(when (re-search-forward
|
(when (re-search-forward
|
||||||
(rx (or (and "<#/" (or "part" "multipart") ">")
|
(rx (or (and "<#/" (or "part" "multipart") ">")
|
||||||
(and "<#part" (* any) ">")))
|
(and "<#part" (* not-newline) ">")))
|
||||||
nil t)
|
nil t)
|
||||||
(setq end (match-beginning 0)))
|
(setq end (match-beginning 0)))
|
||||||
(cons (1+ start) end)))))
|
(cons (1+ start) end)))))
|
||||||
@@ -347,7 +347,7 @@ This returns a hash table of cid -> path."
|
|||||||
(goto-char (match-beginning 1))
|
(goto-char (match-beginning 1))
|
||||||
(let ((start (point))
|
(let ((start (point))
|
||||||
(src (read (current-buffer))))
|
(src (read (current-buffer))))
|
||||||
(when-let ((file (gethash (substring src 4) cid-map)))
|
(when-let* ((file (gethash (substring src 4) cid-map)))
|
||||||
(delete-region start (point))
|
(delete-region start (point))
|
||||||
(insert (prin1-to-string (concat "file://" file))))))))))
|
(insert (prin1-to-string (concat "file://" file))))))))))
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
(require 'sh-script)
|
(require 'sh-script)
|
||||||
(require 'treesit)
|
(require 'treesit)
|
||||||
(require 'rx)
|
(require 'rx)
|
||||||
|
(require 'xref)
|
||||||
|
|
||||||
(defgroup zsh-ts-mode nil
|
(defgroup zsh-ts-mode nil
|
||||||
"Tree-sitter powered Zsh editing."
|
"Tree-sitter powered Zsh editing."
|
||||||
@@ -238,7 +239,7 @@ command.")
|
|||||||
(defun zsh-ts-mode--defun-name (node)
|
(defun zsh-ts-mode--defun-name (node)
|
||||||
"If NODE is a defun node, return its name.
|
"If NODE is a defun node, return its name.
|
||||||
This behaves according to `treesit-defun-name-function'."
|
This behaves according to `treesit-defun-name-function'."
|
||||||
(when-let ((node)
|
(when-let* ((node)
|
||||||
(res (treesit-query-capture node zsh-ts-mode--defun-name-query
|
(res (treesit-query-capture node zsh-ts-mode--defun-name-query
|
||||||
nil nil t)))
|
nil nil t)))
|
||||||
(treesit-node-text (car res) t)))
|
(treesit-node-text (car res) t)))
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
;; Use melpa
|
;; Use melpa
|
||||||
(require 'package)
|
(require 'package)
|
||||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||||
|
;; Safer package upgrades
|
||||||
|
(setopt package-review-policy '(not (archive . "gnu") (archive . "nongnu")))
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
|
|
||||||
;; Ensure use-package is installed
|
;; Ensure use-package is installed
|
||||||
@@ -628,6 +630,7 @@ directory. Otherwise, run `find-file' on that file."
|
|||||||
(require 'mozc nil t)
|
(require 'mozc nil t)
|
||||||
(setq default-input-method "japanese-mozc")
|
(setq default-input-method "japanese-mozc")
|
||||||
(with-eval-after-load 'mozc
|
(with-eval-after-load 'mozc
|
||||||
|
(defvar mozc-candidate-style)
|
||||||
(require 'mozc-posframe)
|
(require 'mozc-posframe)
|
||||||
(setq mozc-candidate-style 'posframe))
|
(setq mozc-candidate-style 'posframe))
|
||||||
|
|
||||||
@@ -1249,6 +1252,7 @@ environment variable accordingly."
|
|||||||
(not (eq (current-local-map)
|
(not (eq (current-local-map)
|
||||||
read-passwd-map)))))
|
read-passwd-map)))))
|
||||||
:config
|
:config
|
||||||
|
(defvar corfu--extra)
|
||||||
(defun my/corfu-move-to-minibuffer ()
|
(defun my/corfu-move-to-minibuffer ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(when completion-in-region--data
|
(when completion-in-region--data
|
||||||
@@ -1276,12 +1280,6 @@ environment variable accordingly."
|
|||||||
(apply oldfun args)))
|
(apply oldfun args)))
|
||||||
(advice-add 'corfu-popupinfo--get-documentation :around
|
(advice-add 'corfu-popupinfo--get-documentation :around
|
||||||
'my/-corfu-popupinfo-close-help-buffer))
|
'my/-corfu-popupinfo-close-help-buffer))
|
||||||
(use-package corfu-terminal
|
|
||||||
:init
|
|
||||||
(corfu-terminal-mode 1)
|
|
||||||
:config
|
|
||||||
(require 'corfu-terminal-popupinfo)
|
|
||||||
(corfu-terminal-popupinfo-mode 1))
|
|
||||||
|
|
||||||
(use-package dabbrev
|
(use-package dabbrev
|
||||||
:ensure nil
|
:ensure nil
|
||||||
@@ -1411,7 +1409,7 @@ If BUFFER is nil, the current buffer is used."
|
|||||||
"Return a list of error strings describing the Racket errors at point."
|
"Return a list of error strings describing the Racket errors at point."
|
||||||
(let (out)
|
(let (out)
|
||||||
(dolist (ov (overlays-at (point)))
|
(dolist (ov (overlays-at (point)))
|
||||||
(when-let ((face (overlay-get ov 'face)))
|
(when-let* ((face (overlay-get ov 'face)))
|
||||||
(cl-case face
|
(cl-case face
|
||||||
(racket-xp-error-face
|
(racket-xp-error-face
|
||||||
(when-let* ((help-echo (get-text-property (point) 'help-echo)))
|
(when-let* ((help-echo (get-text-property (point) 'help-echo)))
|
||||||
@@ -2396,8 +2394,7 @@ line in the block and manually deal with indentation."
|
|||||||
:hook (lisp-mode . my/-format-only-when-sly-running)
|
:hook (lisp-mode . my/-format-only-when-sly-running)
|
||||||
:init
|
:init
|
||||||
(defun my/-apheleia-sly-skip-function ()
|
(defun my/-apheleia-sly-skip-function ()
|
||||||
(or (not (featurep 'sly))
|
(or (not (bound-and-true-p sly-mode))
|
||||||
(not sly-mode)
|
|
||||||
(not (sly-connected-p))))
|
(not (sly-connected-p))))
|
||||||
(defun my/-format-only-when-sly-running ()
|
(defun my/-format-only-when-sly-running ()
|
||||||
"Make apheleia-mode format lisp buffers only when sly is running."
|
"Make apheleia-mode format lisp buffers only when sly is running."
|
||||||
@@ -2412,7 +2409,7 @@ line in the block and manually deal with indentation."
|
|||||||
(inferior-lisp-program "/usr/bin/sbcl")
|
(inferior-lisp-program "/usr/bin/sbcl")
|
||||||
:init
|
:init
|
||||||
(defun my/-sly-fix-special-buffers ()
|
(defun my/-sly-fix-special-buffers ()
|
||||||
(when (string-match-p (rx bos "*" (* any) "*" eos) (buffer-name))
|
(when (string-match-p (rx bos "*" (* not-newline) "*" eos) (buffer-name))
|
||||||
(setq-local show-trailing-whitespace nil)))
|
(setq-local show-trailing-whitespace nil)))
|
||||||
(add-hook 'lisp-mode-hook 'my/-sly-fix-special-buffers)
|
(add-hook 'lisp-mode-hook 'my/-sly-fix-special-buffers)
|
||||||
:config
|
:config
|
||||||
@@ -2665,7 +2662,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
"Return a Jupyter buffer that can evaluate the code MODE is editing.
|
"Return a Jupyter buffer that can evaluate the code MODE is editing.
|
||||||
MODE defaults to `major-mode'."
|
MODE defaults to `major-mode'."
|
||||||
(when-let* ((name (symbol-name (or mode major-mode)))
|
(when-let* ((name (symbol-name (or mode major-mode)))
|
||||||
((string-match (rx bos (group (+? any)) (? "-ts") "-mode" eos)
|
((string-match (rx bos (group (+? not-newline)) (? "-ts") "-mode" eos)
|
||||||
name)))
|
name)))
|
||||||
(my/-find-jupyter-buffer-for-lang (match-string 1 name))))
|
(my/-find-jupyter-buffer-for-lang (match-string 1 name))))
|
||||||
|
|
||||||
@@ -2888,7 +2885,7 @@ argument."
|
|||||||
(defun my/dir-container-p (&optional dir)
|
(defun my/dir-container-p (&optional dir)
|
||||||
"Return non-nil if DIR is a remote directory that is a container.
|
"Return non-nil if DIR is a remote directory that is a container.
|
||||||
Actually, return the method name."
|
Actually, return the method name."
|
||||||
(car (member (file-remote-p default-directory 'method)
|
(car (member (file-remote-p (or dir default-directory) 'method)
|
||||||
'("docker" "podman" "kubernetes" "dockercp" "podmancp"
|
'("docker" "podman" "kubernetes" "dockercp" "podmancp"
|
||||||
"toolbox" "distrobox" "flatpak" "apptainer" "nspawn"))))
|
"toolbox" "distrobox" "flatpak" "apptainer" "nspawn"))))
|
||||||
(defun my/dir-distrobox-p (&optional dir)
|
(defun my/dir-distrobox-p (&optional dir)
|
||||||
@@ -3093,7 +3090,7 @@ Actually, return the method name."
|
|||||||
If no name is given, list all bookmarks instead."
|
If no name is given, list all bookmarks instead."
|
||||||
(if name
|
(if name
|
||||||
(progn
|
(progn
|
||||||
(string-match (rx bos (group (* (not "/"))) (* "/") (group (* any)))
|
(string-match (rx bos (group (* (not "/"))) (* "/") (group (* not-newline)))
|
||||||
name)
|
name)
|
||||||
(let* ((bm-name (match-string 1 name))
|
(let* ((bm-name (match-string 1 name))
|
||||||
(after-path (match-string 2 name))
|
(after-path (match-string 2 name))
|
||||||
@@ -3128,7 +3125,7 @@ If no name is given, list all bookmarks instead."
|
|||||||
(let ((arg (pcomplete-arg)))
|
(let ((arg (pcomplete-arg)))
|
||||||
(if (not (cl-find ?/ arg))
|
(if (not (cl-find ?/ arg))
|
||||||
(pcomplete-here (mapcar (##concat % "/") (bookmark-all-names)))
|
(pcomplete-here (mapcar (##concat % "/") (bookmark-all-names)))
|
||||||
(when (string-match (rx bos (group (+ (not "/"))) (+ "/") (group (* any)))
|
(when (string-match (rx bos (group (+ (not "/"))) (+ "/") (group (* not-newline)))
|
||||||
arg)
|
arg)
|
||||||
(let ((bm-name (match-string 1 arg))
|
(let ((bm-name (match-string 1 arg))
|
||||||
(after-path (match-string 2 arg)))
|
(after-path (match-string 2 arg)))
|
||||||
@@ -3443,7 +3440,7 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
|
|||||||
(when (and (message-point-in-header-p)
|
(when (and (message-point-in-header-p)
|
||||||
(message-beginning-of-header t))
|
(message-beginning-of-header t))
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(when (and (looking-at (rx bol (group (+? any)) ":" (? " ")))
|
(when (and (looking-at (rx bol (group (+? not-newline)) ":" (? " ")))
|
||||||
(funcall (or testfn 'equal) (match-string 1) name))
|
(funcall (or testfn 'equal) (match-string 1) name))
|
||||||
(match-end 0)))))
|
(match-end 0)))))
|
||||||
|
|
||||||
@@ -3473,7 +3470,7 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
|
|||||||
This is the same as `evil-ret' except that it works for links in
|
This is the same as `evil-ret' except that it works for links in
|
||||||
`mu4e-view-mode'."
|
`mu4e-view-mode'."
|
||||||
:type line
|
:type line
|
||||||
(if-let ((url (get-text-property (point) 'mu4e-url)))
|
(if-let* ((url (get-text-property (point) 'mu4e-url)))
|
||||||
(mu4e--view-browse-url-from-binding url)
|
(mu4e--view-browse-url-from-binding url)
|
||||||
(funcall-interactively #'evil-ret count)))
|
(funcall-interactively #'evil-ret count)))
|
||||||
(defun my/-mu4e-setup-view-mode ()
|
(defun my/-mu4e-setup-view-mode ()
|
||||||
|
|||||||
Reference in New Issue
Block a user