DogLooksGood / parinfer-mode

Parinfer for Emacs :)
GNU General Public License v3.0
407 stars 33 forks source link

Problems with smart tab on blank line #48

Open Engelberg opened 7 years ago

Engelberg commented 7 years ago

My .emacs settings relating to parinfer:

(use-package parinfer
  :ensure t
  :config
  (parinfer-strategy-add 'default 'newline-and-indent)
  :bind
  (:map parinfer-mode-map
    ("<tab>" . parinfer-smart-tab:dwim-right)
    ("S-<tab>" . parinfer-smart-tab:dwim-left)
    ("C-i" . parinfer--reindent-sexp)
    ("C-M-i" . parinfer-auto-fix)
    ("C-," . parinfer-toggle-mode)
    :map parinfer-region-mode-map
    ("C-i" . indent-for-tab-command)
    ("<tab>" . parinfer-smart-tab:dwim-right)
    ("S-<tab>" . parinfer-smart-tab:dwim-left) )
  :init
  (progn
    (setq parinfer-extensions
          '(defaults       ; should be included.
         pretty-parens  ; different paren styles for different modes
         smart-yank))   ; Yank behavior depend on mode.
    (add-hook 'clojure-mode-hook #'parinfer-mode)
    (add-hook 'emacs-lisp-mode-hook #'parinfer-mode)))

Example of problem:

(defonce game
  (let [PhaserGame (oget js/Phaser "Game")]
    (PhaserGame. 1152 648 (oget js/Phaser "AUTO") "app" #js{"create" create, "preload" preload})))

In indent mode, position cursor at the end of the let line, and then hit enter, and then hit tab. Instead of moving the cursor to the next reasonable indent position on the blank line, it moves the cursor to the beginning of the next line.

Another issue I'm having is that in indent mode, when the cursor is in the middle of the line and I hit tab to move the line over, the cursor jumps to the end of the line. Is there a way it could stay in its position within the line?

Engelberg commented 7 years ago

Also, in the above example, if you position the cursor on the blank line after that block of code, and hit tab, nothing happens.

DogLooksGood commented 7 years ago

Hi, @Engelberg.

I've load the config above, but I can't reproduce the problem. I need more information.

Is issue exist when only parinfer is enabled?

Engelberg commented 7 years ago

Yes, only when parinfer is enabled. Try hitting enter and tab with the cursor at the end of the final line of the function. Also, try scrolling the buffer so that the cursor is towards the bottom of the visible portion of the buffer. It seems to happen more when the cursor is towards the bottom of the visible area.

bryanbates commented 6 years ago

I'm having a similar issue with (I believe) only use-package, clojure-mode, and parinfer enabled. Below is the (hopefully minimal) .emacs I'm using to recreate/check the problem:

;; Auto-install use-package, adapted from                                                                                                                               
;; http://cachestocaches.com/2015/8/getting-started-use-package/                                                                                                        
(require 'package)
(setq package-enable-at-startup nil)

;; Ensure we have the HTTPS archives                                                                                                                                    
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

;; Added by Package.el.  This must come before configurations of                                                                                                        
;; installed packages.  Don't delete this line.  If you don't want it,                                                                                                  
;; just comment it out by adding a semicolon to the start of the line.                                                                                                  
;; You may delete these explanatory comments.                                                                                                                           
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))
(require 'diminish)
(require 'bind-key)

;; END auto-install of use-package                                                                                                                                      
(use-package clojure-mode
  :ensure t)

(use-package parinfer
  :ensure t
  :config
  (parinfer-strategy-add 'default 'newline-and-indent)
  :bind
  (:map parinfer-mode-map
        ("<tab>" . parinfer-smart-tab:dwim-right)
        ("S-<tab>" . parinfer-smart-tab:dwim-left)
        ("C-i" . parinfer--reindent-sexp)
        ("C-M-i" . parinfer-auto-fix)
        ("C-," . parinfer-toggle-mode)
        :map parinfer-region-mode-map
        ("C-i" . indent-for-tab-command)
        ("<tab>" . parinfer-smart-tab:dwim-right)
        ("S-<tab>" . parinfer-smart-tab:dwim-left))
  :init
  (progn
    (setq parinfer-extensions
          '(defaults       ; should be included.                                                                                                                        
             pretty-parens  ; different paren styles for different modes.                                                                                               
;;             paredit        ; Introduce some paredit commands.                                                                                                        
;;             smart-tab      ; C-b & C-f jump positions and smart shift with tab & S-tab.                                                                              
             smart-yank))   ; Yank behavior depend on mode.                                                                                                             
    (add-hook 'clojure-mode-hook #'parinfer-mode)))