Make complete play nice with auto alignment
This commit is contained in:
parent
e8a2ebb699
commit
15efb41aba
3 changed files with 54 additions and 5 deletions
|
|
@ -177,6 +177,51 @@ Does not use ledger xact"
|
||||||
(if (re-search-backward "\\(\t\\| [ \t]\\)" nil t)
|
(if (re-search-backward "\\(\t\\| [ \t]\\)" nil t)
|
||||||
(goto-char (match-end 0))))))
|
(goto-char (match-end 0))))))
|
||||||
|
|
||||||
|
|
||||||
|
(defun ledger-pcomplete (&optional interactively)
|
||||||
|
"Complete rip-off of pcomplete from pcomplete.el, only added
|
||||||
|
ledger-magic-tab in the previos commads list so that
|
||||||
|
ledger-magic-tab would cycle properly"
|
||||||
|
(interactive "p")
|
||||||
|
(if (and interactively
|
||||||
|
pcomplete-cycle-completions
|
||||||
|
pcomplete-current-completions
|
||||||
|
(memq last-command '(ledger-magic-tab
|
||||||
|
ledger-pcomplete
|
||||||
|
pcomplete-expand-and-complete
|
||||||
|
pcomplete-reverse)))
|
||||||
|
(progn
|
||||||
|
(delete-backward-char pcomplete-last-completion-length)
|
||||||
|
(if (eq this-command 'pcomplete-reverse)
|
||||||
|
(progn
|
||||||
|
(push (car (last pcomplete-current-completions))
|
||||||
|
pcomplete-current-completions)
|
||||||
|
(setcdr (last pcomplete-current-completions 2) nil))
|
||||||
|
(nconc pcomplete-current-completions
|
||||||
|
(list (car pcomplete-current-completions)))
|
||||||
|
(setq pcomplete-current-completions
|
||||||
|
(cdr pcomplete-current-completions)))
|
||||||
|
(pcomplete-insert-entry pcomplete-last-completion-stub
|
||||||
|
(car pcomplete-current-completions)
|
||||||
|
nil pcomplete-last-completion-raw))
|
||||||
|
(setq pcomplete-current-completions nil
|
||||||
|
pcomplete-last-completion-raw nil)
|
||||||
|
(catch 'pcompleted
|
||||||
|
(let* ((pcomplete-stub)
|
||||||
|
pcomplete-seen pcomplete-norm-func
|
||||||
|
pcomplete-args pcomplete-last pcomplete-index
|
||||||
|
(pcomplete-autolist pcomplete-autolist)
|
||||||
|
(pcomplete-suffix-list pcomplete-suffix-list)
|
||||||
|
(completions (pcomplete-completions))
|
||||||
|
(result (pcomplete-do-complete pcomplete-stub completions)))
|
||||||
|
(and result
|
||||||
|
(not (eq (car result) 'listed))
|
||||||
|
(cdr result)
|
||||||
|
(pcomplete-insert-entry pcomplete-stub (cdr result)
|
||||||
|
(memq (car result)
|
||||||
|
'(sole shortest))
|
||||||
|
pcomplete-last-completion-raw))))))
|
||||||
|
|
||||||
(provide 'ldg-complete)
|
(provide 'ldg-complete)
|
||||||
|
|
||||||
;;; ldg-complete.el ends here
|
;;; ldg-complete.el ends here
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,13 @@
|
||||||
(interactive)
|
(interactive)
|
||||||
(remove-overlays))
|
(remove-overlays))
|
||||||
|
|
||||||
(defun ledger-magic-tab ()
|
(defun ledger-magic-tab (&optional interactively)
|
||||||
"Decide what to with with <TAB> .
|
"Decide what to with with <TAB> .
|
||||||
Can be pcomplete, or align-posting"
|
Can be pcomplete, or align-posting"
|
||||||
(interactive)
|
(interactive "p")
|
||||||
(if (and (> (point) 1)
|
(if (and (> (point) 1)
|
||||||
(looking-back "[:A-Za-z0-9]" 1))
|
(looking-back "[:A-Za-z0-9]" 1))
|
||||||
(pcomplete)
|
(ledger-pcomplete interactively)
|
||||||
(ledger-post-align-postings)))
|
(ledger-post-align-postings)))
|
||||||
|
|
||||||
(defvar ledger-mode-abbrev-table)
|
(defvar ledger-mode-abbrev-table)
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,9 @@ position, whichever is closer."
|
||||||
region alight the posting on the current line."
|
region alight the posting on the current line."
|
||||||
(interactive)
|
(interactive)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
(if (or (not (mark))
|
||||||
|
(not (use-region-p)))
|
||||||
|
(set-mark (point)))
|
||||||
(let* ((mark-first (< (mark) (point)))
|
(let* ((mark-first (< (mark) (point)))
|
||||||
(begin-region (if mark-first (mark) (point)))
|
(begin-region (if mark-first (mark) (point)))
|
||||||
(end-region (if mark-first (point-marker) (mark-marker)))
|
(end-region (if mark-first (point-marker) (mark-marker)))
|
||||||
|
|
@ -180,8 +183,9 @@ region alight the posting on the current line."
|
||||||
(goto-char end-region)
|
(goto-char end-region)
|
||||||
(setq end-region (copy-marker (line-end-position)))
|
(setq end-region (copy-marker (line-end-position)))
|
||||||
(goto-char begin-region)
|
(goto-char begin-region)
|
||||||
(setq begin-region (copy-marker (line-beginning-position)))
|
(goto-char
|
||||||
(goto-char begin-region)
|
(setq begin-region
|
||||||
|
(copy-marker (line-beginning-position))))
|
||||||
(while (or (setq acc-col (ledger-next-account (end-of-line-or-region end-region)))
|
(while (or (setq acc-col (ledger-next-account (end-of-line-or-region end-region)))
|
||||||
(< (point) (marker-position end-region)))
|
(< (point) (marker-position end-region)))
|
||||||
(when acc-col
|
(when acc-col
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue