Skip to content

Commit

Permalink
[dap] move posframe package into spacemacs-visual layer
Browse files Browse the repository at this point in the history
1. move posframe package into spacemacs-visual layer for package sharing
2. add `pre-int-posframe` and `post-init-posframe` for further configurations

Rebase to the latest code and remove posframe from translate layer

[translate] allow user to customize renders
  • Loading branch information
rayw000 authored and smile13241324 committed Jul 31, 2022
1 parent ca728d2 commit 43f24df
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
4 changes: 4 additions & 0 deletions layers/+spacemacs/spacemacs-visual/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
hl-todo
popup
popwin
posframe
(zoom-frm :location local)))

(defun spacemacs-visual/init-all-the-icons ()
Expand Down Expand Up @@ -93,6 +94,9 @@

(defun spacemacs-visual/init-popup ())

(defun spacemacs-visual/init-posframe ()
(use-package posframe :defer t))

(defun spacemacs-visual/init-popwin ()
(use-package popwin
:config
Expand Down
7 changes: 2 additions & 5 deletions layers/+tools/dap/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.


(defconst dap-packages
'(dap-mode
posframe))
'(dap-mode))

(defun dap/init-dap-mode ()
(use-package dap-mode
Expand Down Expand Up @@ -135,6 +135,3 @@

;; Set bindings
(apply #'spacemacs/set-leader-keys-for-major-mode mode bindings))))))

(defun dap/init-posframe ()
(use-package posframe))
9 changes: 9 additions & 0 deletions layers/+tools/translate/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [[#read-only][Read-only]]
- [[#face][Face]]
- [[#key-bindings][Key bindings]]
- [[#variables][Variables]]

* Description
This layer is designed for Paragraph-oriented minor mode for
Expand Down Expand Up @@ -80,3 +81,11 @@ color to red, for example.
| ~SPC a t T f~ | Prompt to open the reference file |
| ~SPC a t T b~ | Prompt to select a buffer and set it as the reference buffer |
| ~SPC a t T h~ | Toggle paragraph highlighting |

* Variables
These variables can be used to customize =translate= layer.

| Variable | Default Value | Description |
|------------------------------+---------------+---------------------------------------------------------------------------|
| =translate/paragraph-render= | ='posframe= | Paragraph translation render. Valid values are ='posframe= and ='buffer=. |
| =translate/word-render= | ='posframe= | Word translation render. Valid values are ='posframe= and ='buffer=. |
30 changes: 30 additions & 0 deletions layers/+tools/translate/config.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
;;; funcs.el --- Semantic Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2022 Sylvain Benner & Contributors
;;
;; Author: Ray Wang <rayw.public@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.


(defvar translate/paragraph-render 'posframe
"Paragraph render for displaying translate result.
Currently support `posframe' and `buffer'.")

(defvar translate/word-render 'posframe
"Word render for displaying translate result.
Currently support `posframe' and `buffer'.")
14 changes: 10 additions & 4 deletions layers/+tools/translate/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
(defconst translate-packages
'(
translate-mode
go-translate
posframe))
go-translate))

(defun translate/init-translate-mode ()
"Initialize required packages."
Expand All @@ -48,17 +47,24 @@
(user-error "Make sure there is any word at point, or selection exists"))
(let ((path (gts-path o text)))
(cl-values text path))))
(defun translate//check-and-get-render (render)
(if (equal render 'posframe)
(if (featurep 'posframe)
(gts-posframe-pop-render)
(display-warning 'translate "Missing package `posframe', back to use default `gts-buffer-render'.")
(gts-buffer-render))
(gts-buffer-render)))
(defconst translate//paragraph-translator
(gts-translator
:picker (translate//reference-paragraph-picker)
:engines (list (gts-google-engine) (gts-google-rpc-engine) (gts-bing-engine))
:render (gts-buffer-render))
:render (translate//check-and-get-render translate/paragraph-render))
"Paragraph translator for `go-translate'.")
(defconst translate//word-translator
(gts-translator
:picker (gts-noprompt-picker)
:engines (list (gts-google-engine) (gts-google-rpc-engine) (gts-bing-engine))
:render (gts-posframe-pop-render))
:render (translate//check-and-get-render translate/word-render))
"Word translator for `go-translate'."))))

(defun translate/pre-init-posframe ()
Expand Down

0 comments on commit 43f24df

Please sign in to comment.