Abstract popwin defuns
This commit is contained in:
parent
0cd60e5ae8
commit
5193970d8f
13 changed files with 39 additions and 110 deletions
|
@ -17,10 +17,8 @@
|
|||
helm-find-files-doc-header nil
|
||||
|
||||
helm-candidate-number-limit 30
|
||||
helm-bookmark-show-location t
|
||||
;; let popwin handle this
|
||||
helm-split-window-default-side 'other
|
||||
helm-split-window-preferred-function 'narf/helm-split-window)
|
||||
helm-bookmark-show-location t)
|
||||
|
||||
:config
|
||||
(evil-set-initial-state 'helm-mode 'emacs)
|
||||
(require 'helm-files)
|
||||
|
@ -116,57 +114,7 @@
|
|||
helm-ag-project-root
|
||||
helm-ag-pop-stack
|
||||
helm-ag-buffers
|
||||
helm-ag-clear-stack)
|
||||
:config
|
||||
(defadvice helm-ag--edit-abort (around helm-ag-edit-abort-popwin-compat activate)
|
||||
(cl-letf (((symbol-function 'select-window) 'ignore)) ad-do-it))
|
||||
(defadvice helm-ag--edit-commit (around helm-ag-edit-commit-popwin-compat activate)
|
||||
(cl-letf (((symbol-function 'select-window) 'ignore)) ad-do-it))
|
||||
|
||||
;; I remove any attempt to kill the helm-ag window, because popwin handles it.
|
||||
(defun helm-ag--edit (_candidate)
|
||||
(let ((default-directory helm-ag--default-directory))
|
||||
(with-current-buffer (get-buffer-create "*helm-ag-edit*")
|
||||
(erase-buffer)
|
||||
(setq-local helm-ag--default-directory helm-ag--default-directory)
|
||||
(let (buf-content)
|
||||
(with-current-buffer (get-buffer "*helm-ag*")
|
||||
(goto-char (point-min))
|
||||
(forward-line 1)
|
||||
(let* ((body-start (point))
|
||||
(marked-lines (cl-loop for ov in (overlays-in body-start (point-max))
|
||||
when (eq 'helm-visible-mark (overlay-get ov 'face))
|
||||
return (helm-marked-candidates))))
|
||||
(if (not marked-lines)
|
||||
(setq buf-content (buffer-substring-no-properties
|
||||
body-start (point-max)))
|
||||
(setq buf-content (concat (mapconcat 'identity marked-lines "\n") "\n")))))
|
||||
(insert buf-content)
|
||||
(add-text-properties (point-min) (point-max)
|
||||
'(read-only t rear-nonsticky t front-sticky t))
|
||||
(let ((inhibit-read-only t))
|
||||
(setq header-line-format
|
||||
(format "[%s] C-c C-c: Commit, C-c C-k: Abort"
|
||||
(abbreviate-file-name helm-ag--default-directory)))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^\\(\\(?:[^:]+:\\)\\{1,2\\}\\)\\(.*\\)$" nil t)
|
||||
(let ((file-line-begin (match-beginning 1))
|
||||
(file-line-end (match-end 1))
|
||||
(body-begin (match-beginning 2))
|
||||
(body-end (match-end 2)))
|
||||
(add-text-properties file-line-begin file-line-end
|
||||
'(face font-lock-function-name-face
|
||||
intangible t))
|
||||
(remove-text-properties body-begin body-end '(read-only t))
|
||||
(set-text-properties body-end (1+ body-end)
|
||||
'(read-only t rear-nonsticky t))))))))
|
||||
(popwin:display-buffer (get-buffer "*helm-ag-edit*"))
|
||||
;; (other-window 1)
|
||||
;; (switch-to-buffer (get-buffer "*helm-ag-edit*"))
|
||||
(goto-char (point-min))
|
||||
(setq next-error-function 'compilation-next-error-function)
|
||||
(setq-local compilation-locs (make-hash-table :test 'equal :weakness 'value))
|
||||
(use-local-map helm-ag-edit-map)))
|
||||
helm-ag-clear-stack))
|
||||
|
||||
(use-package helm-org
|
||||
:commands (helm-org-in-buffer-headings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue