Pin Emacs buffers to windows (for cscope)

前端 未结 2 564
名媛妹妹
名媛妹妹 2020-11-30 00:24

For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code.

Normally, I have 2 windows in a split (

2条回答
  •  无人及你
    2020-11-30 00:33

    Put this in your .emacs file:

    ;; Toggle window dedication
    
    (defun toggle-window-dedicated ()
    
    "Toggle whether the current active window is dedicated or not"
    
    (interactive)
    
    (message 
    
     (if (let (window (get-buffer-window (current-buffer)))
    
           (set-window-dedicated-p window 
    
            (not (window-dedicated-p window))))
    
        "Window '%s' is dedicated"
    
        "Window '%s' is normal")
    
     (current-buffer)))
    

    Then bind it to some key - I use the Pause key:

    (global-set-key [pause] 'toggle-window-dedicated)
    

    And then use it to "dedicate" the window you want locked. then cscope can only open files from its result window in some OTHER window. Works a charm. I specifically use it for exactly this purpose - keeping one source file always on screen, while using cscope in a second buffer/window, and looking at cscope results in a third.

提交回复
热议问题