From 772febedb7f582a200f546e5bd4187ce5cea2814 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 16 Aug 2018 17:36:05 +0200 Subject: [PATCH] lang/rest: fix za, zm & zr fold keys --- modules/lang/rest/autoload.el | 28 ++++++++++++++++++++++++++++ modules/lang/rest/config.el | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 modules/lang/rest/autoload.el diff --git a/modules/lang/rest/autoload.el b/modules/lang/rest/autoload.el new file mode 100644 index 000000000..0562764b0 --- /dev/null +++ b/modules/lang/rest/autoload.el @@ -0,0 +1,28 @@ +;;; lang/rest/autoload.el -*- lexical-binding: t; -*- + +(defun +rest-request-at-point-p (&optional pos) + (save-excursion + (if pos (goto-char pos)) + (beginning-of-line) + (and (re-search-forward restclient-method-url-regexp + (line-end-position) t) + (not (nth 4 (syntax-ppss)))))) + +;;;###autoload +(defun +rest/dwim-at-point () + "TODO" + (interactive) + (when (+rest-request-at-point-p) + (restclient-http-send-current-stay-in-window))) + +;;;###autoload +(defun +rest/fold-all () + "TODO" + (interactive) + (save-excursion + (goto-char (point-min)) + (let ((last (point))) + (while (and (restclient-jump-next) + (not (= last (setq last (point))))) + (unless (overlays-at (line-end-position)) + (restclient-toggle-body-visibility)))))) diff --git a/modules/lang/rest/config.el b/modules/lang/rest/config.el index 0e6340597..5599e137e 100644 --- a/modules/lang/rest/config.el +++ b/modules/lang/rest/config.el @@ -14,6 +14,10 @@ (map! :mode restclient-mode :n [M-return] 'restclient-http-send-current + :n "za" #'restclient-toggle-body-visibility + :n "zm" #'+rest/fold-all + :n "zr" #'outline-show-all + :localleader :desc "Execute HTTP request" :n "e" 'restclient-http-send-current :desc "Execute raw HTTP request" :n "E" 'restclient-http-send-current-raw