wakib-emacs icon indicating copy to clipboard operation
wakib-emacs copied to clipboard

A few small issues

Open shaund opened this issue 4 years ago • 3 comments

These are mostly small things, so I didn't want to create a bunch of issues.

Also nice work overall. I've tried to use emacs several times in the past, and always end up giving up because of how much work it is to get it to behave like all the other programs I use. So far, this comes closest.

I'm on Windows 10, GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-08-29.

BUGS

  • [ ] 1. I get these warnings when starting for the first time.
Warning (bytecomp): Unused lexical argument ‘window’
Warning (bytecomp): reference to free variable ‘mc/cycle’
Warning (bytecomp): the following functions are not known to be defined: mc/cursor-beg,
    mc/cursor-end, return-from
Warning (bytecomp): ‘set-temporary-overlay-map’ is an obsolete function (as of 24.4); use ‘set-transient-map’ instead.
Warning (bytecomp): looking-back called with 1 argument, but requires 2-3
Warning (bytecomp): defcustom for ‘mc/mode-line’ fails to specify type [2 times]
  • [ ] 2. C-w kills unsaved buffers without prompting. Beyond making sure it prompts, I think a more expected behavior in general would be to kill window and buffer if buffer isn't open anywhere else, otherwise just window.
  • [x] 3. shift-select not enabled in org mode
  • [ ] 4. resizing mini-buffer doesn't expand contents. For example, do C-h b, resize with mouse. Result: the list of available bindings takes up the same amount of space.
  • [ ] 5. resizing frame (that is, the emacs window itself), hides which-key instead of making it show more. Moving the mouse over a modeline and letting a popup show brings which-key back up
  • [x] 6. which-key doesn't show C-d bindings
  • [x] 7. C-h b still shows C-x instead of C-e
  • [x] 8. which-key-idle-delay is high. Maybe put at something like 0.1

UI

  • [ ] 1. ctrl-mouseup/down doesn't zoom. See code at bottom
  • [ ] 2. It'd be nice to have tabs, or at least have something like C-tab switch between buffers (this binding would conflict with (org-force-cycle-archived) though). Also related would be making <mouse-4> and <mouse-5> (back/forward) switch between windows (like VSCode) or tabs/buffers (Sublime).
  • [ ] 3. C-c C-c is an easy keybind to press, since it's just C-c-c. Given how much it's used in org, having it instead be C-d C-d would mimic that ease of use (and actually be even easier since it's on the home row and aligned with Ctrl if you've remapped Caps Lock).
  • [ ] 4. A more expected behaviour for <mouse-2> (middle/wheel click-and-drag) would be multi-cursors
  • [x] 5. Ctrl-Enter and Ctrl-Shift-Enter inserting lines below/above would mimic other editors
  • [ ] 6. Instead of <C-return> for CUA rectangle, use something more like Sublime and VSCode (Ctrl-Alt-up/down arrows). Could use C-M-i and C-M-k in addition to arrows. See C-i remapping at bottom. This would also free up Ctrl-Enter for insert line below.
  • [ ] 7. desktop-save-mode should probably be enabled by default like Sublime and VSCode
  • [x] 8. Add name of buffer and whether modified. See code at bottom.

CODE SNIPPETS

for zooming

; from https://stackoverflow.com/a/60641769/963450
;; Resize the whole frame, and not only a window
;; Adapted from https://stackoverflow.com/a/24714383/5103881
(defun acg/zoom-frame (&optional amt frame)
  "Increase FRAME font size by amount AMT. Defaults to selected
frame if FRAME is nil, and to 1 if AMT is nil."
  (interactive "p")
  (let* ((frame (or frame (selected-frame)))
         (font (face-attribute 'default :font frame))
         (size (font-get font :size))
         (amt (or amt 1))
         (new-size (+ size amt)))
    (set-frame-font (font-spec :size new-size) t `(,frame))
    (message "Frame's font new size: %d" new-size)))

(defun acg/zoom-frame-out (&optional amt frame)
  "Call `acg/zoom-frame' with negative argument."
  (interactive "p")
  (acg/zoom-frame (- (or amt 1)) frame))

I use these bindings (inside a (defvar my-map (let ((map (make-keymap))))

(define-key map (kbd "<C-wheel-up>") 'text-scale-increase)
(define-key map (kbd "<C-wheel-down>") 'text-scale-decrease)
(define-key map (kbd "<C-S-wheel-up>") 'acg/zoom-frame)
(define-key map (kbd "<C-S-wheel-down>") 'acg/zoom-frame-out)

C-i not insert tab

(define-key input-decode-map (kbd "C-i") (kbd "H-i"))
(define-key input-decode-map (kbd "C-S-i") (kbd "H-S-i"))

then bind to whatever (in this case arrow up) like (define-key map (kbd "H-i") (kbd "<up>"))

Buffer name in title bar

(use-package emacs
  :config
  (setq frame-title-format
    '((:eval (if (buffer-file-name) (abbreviate-file-name (buffer-file-name)) "%b"))" [%+]"))

shaund avatar Mar 24 '20 07:03 shaund

Thanks for the input. And this is a lot to go through and some of these might need to get their own issues because it would take some back and forth to come to a proper solution, and some parts will be resolved faster than others. So let me try to give a bit of feedback on some of these and my mindset to many of these.

BUGS

  1. Agreed. This is something that was bothering me when I first started since I didn't want warnings to popup on a working install. Unfortunately these are all compiler warnings from the many packages that are used here. I was thinking of suppressing all warnings, but if something did go wrong the user would not know about it, so while I am not happy with it I left it as is, since I couldn't find a solution that didn't feel worse than having superfluous warnings. I might have to submit pull requests on each of the packages used to have them handle it upstream.

  2. TODO: C-w actually confirms unsaved buffers, but only on visited buffers (one with a file on disk) The problem is Emacs typically differentiates between visited and unvisited buffers with the latter being a third class citizen of the buffer world. None of the built in solutions actually prompt for unvisited file, so I guess I need to roll my own solution. I am unsure whether killing the window is the behavior that I am looking for, especially since this can be used a lot in single window. and window manipulation works (new window or closing windows) are right next to each other. So it kinda makes sense in that way even though I can't help but think there might be better bindings for them. But I still like C-w dealing with buffers rather than windows.

  3. Done

  4. Emacs acts all strange when resizing. I will have to look into this to see if or how it can be done.

  5. See above.

  6. I really wish Emacs made it easier to change C-c and C-x bindings. The only way to do it isn't that straightforward and will cause certain things to not work. C-x shows up on which-key I am guessing because it points to a specific keymap. I haven't looked at the source code yet, but I think I can modify which-key to properly act on C-d.

  7. This actually seems to show C-c instead of C-d as well. This is an issue because C-h b uses describe-buffer-bindings to get a listing and that is a built-in function written in C. Also, the function doesn't return the list of values but rather prints them onto the current buffer directly. I think it is possible to wrap an advice around that function that will get it to output to a temp-buffer and replace the prefixes there before placing into the actual buffer.

  8. Done

I will go over the UI part of your suggestions tomorrow. Most of them are simple enough though. Thanks for the help.

darkstego avatar Mar 25 '20 03:03 darkstego

Since we're into making emacs more akin to other IDEs, I'll share this :

;; Drag stuff
(use-package drag-stuff) ;; Grab the package from Melpa.
(require 'drag-stuff) ;; No idea what this does.
(drag-stuff-global-mode t) ;; To enable globally.
(drag-stuff-define-keys) ;; To use its keybindings, ALT-arrows.

(define-key wakib-keys-overriding-map (kbd "C-M-S-j") 'drag-stuff-left)
(define-key wakib-keys-overriding-map (kbd "C-M-S-l") 'drag-stuff-right)
(define-key wakib-keys-overriding-map (kbd "C-M-S-i") 'drag-stuff-up)
(define-key wakib-keys-overriding-map (kbd "C-M-S-k") 'drag-stuff-down)

For the package drag-stuff, very useful. Default behaviour in Gedit and Eclipse among many others.

sinekonata avatar Apr 01 '20 20:04 sinekonata

Changed which-key and C-h b bindings as best I can. These changes were pushed to wakib-keys so a package update needs to be run in Emacs to get the changes. There are some bugs in Emacs describe-buffer-bindings that occur when keys like C-c are bound to something else. So while it isn't perfect, it does the job so far.

darkstego avatar Apr 30 '20 21:04 darkstego