* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display @ 2020-03-28 4:03 ` Yuan Fu 2020-03-29 9:01 ` martin rudalics 2020-04-14 1:09 ` bug#40268: Fwd: " Yuan Fu 0 siblings, 2 replies; 8+ messages in thread From: Yuan Fu @ 2020-03-28 4:03 UTC (permalink / raw) To: 40268 [-- Attachment #1: Type: text/plain, Size: 609 bytes --] Before this change, stepping and other gdb command handlers use 'gud-display-line’ and 'gdb-goto-breakpoint' uses 'gdb-display-source-buffer'. Now whenever gdb-mi code tries to open a source buffer, 'gdb-display-source-buffer’ is used. Also, we simplify the logic in 'gdb-display-source-buffer’ and add a feature to limit the maximum number of source windows. From a user’s perspective, this change solves two problems: 1. The behavior difference between jumping to break point and stepping (and other command) 2. Gdb-mi opening more windows than I wanted for displaying source files. Yuan [-- Attachment #2: source-window.patch --] [-- Type: application/octet-stream, Size: 8675 bytes --] From ad34237cdc7c06e7edfcb593e8c732c6a040a7cb Mon Sep 17 00:00:00 2001 From: Yuan Fu <casouri@gmail.com> Date: Tue, 21 Jan 2020 16:23:57 -0500 Subject: [PATCH] Unify and improve gdb-mi source buffer display logic Unify the behavior of source buffer display for gdb-mi. Before this change, stepping and other gdb command handlers use 'gud-display-line' and 'gdb-goto-breakpoint' uses 'gdb-display-source-buffer'. Now whenever gdb-mi code tries to open a source buffer, 'gdb-display-source-buffer' is used. Also, we simplify the logic in 'gdb-display-source-buffer' and add a feature to limit the maximum number of source windows. * lisp/progmodes/gdb-mi.el (gdb-source-window): Remove variable, changed to 'gdb-source-window-list'. (gdb-source-window-list, gdb-max-source-window-count): New variable. (gdb-display-source-buffer-action, gdb-max-source-window-count): New custom variable. (gdb-init-1, gdb-setup-windows, gdb-restore-windows): Use 'gdb-source-window' rather than 'gdb-source-window-list'. (gdb-display-source-buffer): Use new logic. (gdb-goto-breakpoint): Remove 'display-buffer' and don't set 'gdb-source-buffer' anymore. * lisp/progmodes/gud.el (gud-display-line): Remove 'display-buffer' and don't set 'gdb-source-buffer' anymore. --- lisp/progmodes/gdb-mi.el | 65 +++++++++++++++++++++++++++++----------- lisp/progmodes/gud.el | 26 ++++++++-------- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index e4233dacaf..5f31a22f22 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -211,7 +211,9 @@ gdb-handler-list (defvar gdb-source-file-list nil "List of source files for the current executable.") (defvar gdb-first-done-or-error t) -(defvar gdb-source-window nil) +(defvar gdb-source-window-list nil + "List of windows used for displaying source files. +Sorted in most recently visited first order.") (defvar gdb-inferior-status nil) (defvar gdb-continuation nil) (defvar gdb-supports-non-stop nil) @@ -589,6 +591,21 @@ gdb-show-main :group 'gdb :version "22.1") +(defcustom gdb-display-source-buffer-action nil + "`display-buffer' action used when GDB displaying a source buffer." + :type 'list + :group 'gdb + :version "28.1") + +(defcustom gdb-max-source-window-count 1 + "Maximum number of source windows to use. +Until there are such number of source windows on screen, GDB +tries to open a new window when visiting a new source file; if +there are, GDB will start to reuse existing source windows." + :type 'number + :grou 'gdb + :version "28.1") + (defvar gdbmi-debug-mode nil "When non-nil, print the messages sent/received from GDB/MI in *Messages*.") @@ -922,7 +939,7 @@ gdb-init-1 gdb-first-done-or-error t gdb-buffer-fringe-width (car (window-fringes)) gdb-debug-log nil - gdb-source-window nil + gdb-source-window-list nil gdb-inferior-status nil gdb-continuation nil gdb-buf-publisher '() @@ -2002,17 +2019,31 @@ gdb-show-stop-p ;; GDB frame (after up, down etc). If no GDB frame is visible but the last ;; visited breakpoint is, use that window. (defun gdb-display-source-buffer (buffer) - (let* ((last-window (if gud-last-last-frame - (get-buffer-window - (gud-find-file (car gud-last-last-frame))))) - (source-window (or last-window - (if (and gdb-source-window - (window-live-p gdb-source-window)) - gdb-source-window)))) - (when source-window - (setq gdb-source-window source-window) - (set-window-buffer source-window buffer)) - source-window)) + "Find a window to display BUFFER. +Always find a window to display buffer, and return it." + ;; This function doesn't take care of setting up source window(s) at startup, + ;; that's handled by `gdb-setup-windows' (if `gdb-many-windows' is non-nil). + ;; If `buffer' is already shown in a window, use that window. + (or (get-buffer-window buffer) + (progn + ;; First, update the window list. + (setq gdb-source-window-list + (cl-remove-if-not #'window-live-p + gdb-source-window-list)) + ;; Should we create a new window or reuse one? + (if (> gdb-max-source-window-count + (length gdb-source-window-list)) + ;; Create a new window, push it to window list and return it. + (car (push (display-buffer buffer gdb-display-source-buffer-action) + gdb-source-window-list)) + ;; Reuse a window, we use the oldest window and put that to + ;; the front of the window list. + (let ((last-win (car (last gdb-source-window-list))) + (rest (butlast gdb-source-window-list))) + (set-window-buffer last-win buffer) + (setq gdb-source-window-list + (cons last-win rest)) + last-win))))) (defun gdbmi-start-with (str offset match) @@ -3981,9 +4012,7 @@ gdb-goto-breakpoint (let* ((buffer (find-file-noselect (if (file-exists-p file) file (cdr (assoc bptno gdb-location-alist))))) - (window (or (gdb-display-source-buffer buffer) - (display-buffer buffer)))) - (setq gdb-source-window window) + (window (gdb-display-source-buffer buffer))) (with-current-buffer buffer (goto-char (point-min)) (forward-line (1- (string-to-number line))) @@ -4597,7 +4626,7 @@ gdb-setup-windows ;; Put buffer list in window if we ;; can't find a source file. (list-buffers-noselect)))) - (setq gdb-source-window (selected-window)) + (setq gdb-source-window-list (list (selected-window))) (let ((win4 (split-window-right))) (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-inferior-io) nil win4)) @@ -4639,7 +4668,7 @@ gdb-restore-windows (if gud-last-last-frame (gud-find-file (car gud-last-last-frame)) (gud-find-file gdb-main-file))) - (setq gdb-source-window win))))) + (setq gdb-source-window-list (list win)))))) ;; Called from `gud-sentinel' in gud.el: (defun gdb-reset () diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 567f452b93..dda7fd6ef0 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -2826,9 +2826,11 @@ gud-display-line (buffer (with-current-buffer gud-comint-buffer (gud-find-file true-file))) - (window (and buffer - (or (get-buffer-window buffer) - (display-buffer buffer '(nil (inhibit-same-window . t)))))) + (window (when buffer (if (eq gud-minor-mode 'gdb-mi) + (gdb-display-source-buffer buffer) + ;; Gud still has the old behavior. + (or (get-buffer-window buffer) + (display-buffer buffer '(nil (inhibit-same-window . t))))))) (pos)) (when buffer (with-current-buffer buffer @@ -2858,9 +2860,7 @@ gud-display-line (widen) (goto-char pos)))) (when window - (set-window-point window gud-overlay-arrow-position) - (if (eq gud-minor-mode 'gdbmi) - (setq gdb-source-window window)))))) + (set-window-point window gud-overlay-arrow-position))))) ;; The gud-call function must do the right thing whether its invoking ;; keystroke is from the GUD buffer itself (via major-mode binding) @@ -2908,14 +2908,14 @@ gud-format-command (setq subst (gud-find-class (if insource - (buffer-file-name) - (car frame)) + (buffer-file-name) + (car frame)) (if insource - (save-restriction - (widen) - (+ (count-lines (point-min) (point)) - (if (bolp) 1 0))) - (cdr frame))))) + (save-restriction + (widen) + (+ (count-lines (point-min) (point)) + (if (bolp) 1 0))) + (cdr frame))))) ((eq key ?p) (setq subst (if arg (int-to-string arg))))) (setq result (concat result (match-string 1 str) subst))) -- 2.25.1 [-- Attachment #3: Type: text/plain, Size: 11199 bytes --] In GNU Emacs 27.0.60 (build 1, x86_64-apple-darwin19.3.0, NS appkit-1894.30 Version 10.15.3 (Build 19D76)) of 2020-02-25 built on missSilver Repository revision: f27187f963e9e36435b508e29256e048799e0ff2 Repository branch: emacs-27 Windowing system distributor 'Apple', version 10.3.1894 System Description: Mac OS X 10.15.4 Recent messages: Checking 34 files in /Users/yuan/emacs/lisp/emulation... Checking 180 files in /Users/yuan/emacs/lisp/emacs-lisp... Checking 24 files in /Users/yuan/emacs/lisp/cedet... Checking 59 files in /Users/yuan/emacs/lisp/calendar... Checking 87 files in /Users/yuan/emacs/lisp/calc... Checking 113 files in /Users/yuan/emacs/lisp/obsolete... Checking for load-path shadows...done Auto-saving... Buffer *unsent mail to bug-gnu-emacs@gnu.org* modified; kill anyway? (y or n) y C-c C-c is undefined Configured using: 'configure --with-modules --with-pdumper=yes --oldincludedir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2/' Configured features: RSVG GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS XIM NS MODULES THREADS PDUMPER LCMS2 Important settings: value of $LC_CTYPE: UTF-8 value of $LANG: en_CN.UTF-8 locale-coding-system: utf-8-unix Major mode: Shell-script Minor modes in effect: global-semanticdb-minor-mode: t global-semantic-idle-scheduler-mode: t semantic-mode: t sh-electric-here-document-mode: t global-magit-file-mode: t magit-file-mode: t global-git-commit-mode: t async-bytecomp-package-mode: t shell-dirtrack-mode: t diff-hl-mode: t color-outline-mode: t hi-lock-mode: t desktop-save-mode: t helpful-html-manual-mode: t yas-global-mode: t yas-minor-mode: t form-feed-mode: t minibuffer-electric-default-mode: t flycheck-mode: t flyspell-mode: t minions-mode: t eyebrowse-mode: t savehist-mode: t global-hl-todo-mode: t hl-todo-mode: t global-highlight-parentheses-mode: t highlight-parentheses-mode: t rainbow-delimiters-mode: t global-undo-tree-mode: t undo-tree-mode: t electric-pair-mode: t winner-mode: t ivy-prescient-mode: t prescient-persist-mode: t recentf-mode: t which-key-mode: t general-override-mode: t outline-minor-mode: t counsel-mode: t ivy-mode: t company-mode: t override-global-mode: t tooltip-mode: t global-eldoc-mode: t electric-quote-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t hs-minor-mode: t Load-path shadows: /Users/yuan/.emacs.d/ranch/winman/windman hides /Users/yuan/.emacs.d/ranch/windman/windman /Users/yuan/.emacs.d/ranch/separedit/cask-bootstrap hides /Users/yuan/.emacs.d/ranch/comment-edit/cask-bootstrap /Users/yuan/.emacs.d/ranch/esup/esup-child hides /Users/yuan/.emacs.d/package/esup-20200120.740/esup-child /Users/yuan/.emacs.d/ranch/esup/esup hides /Users/yuan/.emacs.d/package/esup-20200120.740/esup /Users/yuan/.emacs.d/ranch/julia-mode/julia-mode hides /Users/yuan/.emacs.d/package/julia-mode-20190813.1326/julia-mode /Users/yuan/.emacs.d/ranch/julia-mode/julia-latexsubs hides /Users/yuan/.emacs.d/package/julia-mode-20190813.1326/julia-latexsubs /Users/yuan/.emacs.d/ranch/matlab-emacs/mlint hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/mlint /Users/yuan/.emacs.d/ranch/matlab-emacs/company-matlab-shell hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/company-matlab-shell /Users/yuan/.emacs.d/ranch/matlab-emacs/linemark hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/linemark /Users/yuan/.emacs.d/ranch/matlab-emacs/semanticdb-matlab hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/semanticdb-matlab /Users/yuan/.emacs.d/ranch/matlab-emacs/semantic-matlab hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/semantic-matlab /Users/yuan/.emacs.d/ranch/matlab-emacs/srecode-matlab hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/srecode-matlab /Users/yuan/.emacs.d/ranch/matlab-emacs/matlab hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/matlab /Users/yuan/.emacs.d/ranch/matlab-emacs/cedet-matlab hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/cedet-matlab /Users/yuan/.emacs.d/ranch/matlab-emacs/tlc hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/tlc /Users/yuan/.emacs.d/ranch/matlab-emacs/matlab-publish hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/matlab-publish /Users/yuan/.emacs.d/ranch/matlab-emacs/matlab-mode-pkg hides /Users/yuan/.emacs.d/package/matlab-mode-20180928.1526/matlab-mode-pkg /Users/yuan/.emacs.d/package/faceup-20170925.1946/faceup hides /Users/yuan/emacs/lisp/emacs-lisp/faceup Features: (shadow sort mail-extr emacsbug sendmail face-remap rfc1345 quail semantic/tag-write semantic/tag-file semantic/bovine/c hideif semantic/bovine/c-by semantic/lex-spp semantic/bovine/gcc semantic/analyze/refs semantic/db-file data-debug cedet-files semantic/bovine/scm semantic/decorate/include semantic/db-find semantic/db-ref semantic/decorate/mode semantic/decorate pulse semantic/dep semantic/bovine/scm-by semantic/bovine semantic/db-mode semantic/idle semantic/analyze semantic/sort semantic/scope semantic/analyze/fcn semantic/db eieio-base semantic/format ezimage semantic/tag-ls semantic/find semantic/ctxt semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local cedet cc-mode-expansions cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ls-lisp ess-custom apropos sh-script smie executable geiser-mode geiser-xref geiser-compile geiser-debug geiser-gambit geiser-chibi geiser-mit geiser-chez geiser-chicken geiser-racket geiser-guile ghelp-geiser console-buffer geiser geiser-repl geiser-image geiser-company geiser-doc geiser-menu geiser-edit geiser-completion geiser-autodoc geiser-eval geiser-connection tq geiser-syntax geiser-log geiser-popup view geiser-impl geiser-custom geiser-base scheme vc-mtn vc-hg bug-reference magit-patch-changelog magit-patch magit-bookmark magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func magit-diff smerge-mode magit-core magit-autorevert autorevert magit-margin magit-transient magit-process magit-mode transient git-commit magit-git magit-section magit-utils crm log-edit pcvs-util add-log with-editor async-bytecomp async shell misearch multi-isearch vc-git vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs bookmark server cl-print gnutls mm-archive message rfc822 mml mml-sec epa derived gnus-util rmail rmail-loaddefs text-property-search mailabbrev gmm-utils mailheader mm-decode mm-bodies mm-encode mail-utils network-stream url-http mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc puny url-cache url-auth url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf mailcap epg epg-config hideshow diff-hl vc-dir vc vc-dispatcher diff-mode color-outline hi-lock company-oddmuse company-keywords company-etags etags fileloop generator company-gtags company-dabbrev-code company-dabbrev company-files company-capf company-cmake company-xcode company-clang company-semantic company-eclim company-template company-bbdb desktop frameset trivial-copy ghelp ghelp-eglot ghelp-helpful ghelp-builtin cus-edit centaur-tabs centaur-tabs-interactive centaur-tabs-functions centaur-tabs-elements powerline powerline-separators powerline-themes cus-start cus-load luna-general-config pause utility transform flywrap yasnippet sly-el-indent sly-cl-indent cl-indent cl all-the-icons all-the-icons-faces data-material data-weathericons data-octicons data-fileicons data-faicons data-alltheicons memoize form-feed minibuf-eldef eglot array filenotify jsonrpc ert pp ewoc debug flymake-proc flymake warnings url-util flycheck flyspell ispell outshine outshine-org-cmds outorg isolate inline expand-region text-mode-expansions the-org-mode-expansions er-basic-expansions thingatpt expand-region-core expand-region-custom ws-butler minions eyebrowse savehist buffer-move windmove hl-todo highlight-parentheses rainbow-delimiters doom-cyberpunk-theme undo-tree diff doom-one-light-theme elec-pair winner doom-themes doom-themes-base windman aggressive-indent find-char ivy-prescient prescient recentf-ext recentf tree-widget wid-edit which-key general helpful imenu trace edebug backtrace info-look f dash-functional help-fns radix-tree elisp-refs s loop dash org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete org-list org-faces org-entities time-date noutline outline org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat advice org-macs org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs counsel xdg xref project dired dired-loaddefs compile comint ansi-color swiper cl-extra help-mode ivy delsel ring colir color ivy-overlay company edmacro kmacro pcase use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key use-package-core finder-inf tex-site proof-site proof-autoloads info cowboy package easymenu browse-url url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars cl-loaddefs cl-lib lunary lunary-ui easy-mmode luna-f rx seq byte-opt gv bytecomp byte-compile cconv tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads kqueue cocoa ns lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 489882 97798) (symbols 48 40858 45) (strings 32 193314 9271) (string-bytes 1 4564854) (vectors 16 58289) (vector-slots 8 1900639 84204) (floats 8 468 326) (intervals 56 7219 1188) (buffers 1000 40)) ^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-03-28 4:03 ` bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display Yuan Fu @ 2020-03-29 9:01 ` martin rudalics 2020-03-29 17:27 ` Yuan Fu 2020-04-14 1:09 ` bug#40268: Fwd: " Yuan Fu 1 sibling, 1 reply; 8+ messages in thread From: martin rudalics @ 2020-03-29 9:01 UTC (permalink / raw) To: Yuan Fu, 40268 > From a user’s perspective, this change solves two problems: 1. The > behavior difference between jumping to break point and stepping (and > other command) 2. Gdb-mi opening more windows than I wanted for > displaying source files. The patch doesn't apply here. Searching for :group 'gdb :version "22.1") (defvar gdbmi-debug-mode nil "When non-nil, print the messages sent/received from GDB/MI in *Messages*.") fails. Thanks, martin ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-03-29 9:01 ` martin rudalics @ 2020-03-29 17:27 ` Yuan Fu 2020-03-31 9:15 ` martin rudalics 0 siblings, 1 reply; 8+ messages in thread From: Yuan Fu @ 2020-03-29 17:27 UTC (permalink / raw) To: martin rudalics; +Cc: 40268 [-- Attachment #1: Type: text/plain, Size: 690 bytes --] > On Mar 29, 2020, at 5:01 AM, martin rudalics <rudalics@gmx.at> wrote: > > > From a user’s perspective, this change solves two problems: 1. The > > behavior difference between jumping to break point and stepping (and > > other command) 2. Gdb-mi opening more windows than I wanted for > > displaying source files. > > The patch doesn't apply here. Searching for > > :group 'gdb > :version "22.1") > > (defvar gdbmi-debug-mode nil > "When non-nil, print the messages sent/received from GDB/MI in *Messages*.") > > > fails. > > Thanks, martin > Ah, I see. I should have generate this patch against the latest history. This one should be ok. Yuan [-- Attachment #2: source-window.patch --] [-- Type: application/octet-stream, Size: 9332 bytes --] From 8fb48ccf1b2f3e03e782c6aed7273ede843bb9d1 Mon Sep 17 00:00:00 2001 From: Yuan Fu <casouri@gmail.com> Date: Sun, 29 Mar 2020 10:20:53 -0400 Subject: [PATCH] Unify and improve gdb-mi source buffer display logic Unify the behavior of source buffer display for gdb-mi. Before this change, stepping and other gdb command handlers use 'gud-display-line' and 'gdb-goto-breakpoint' uses 'gdb-display-source-buffer'. Now whenever gdb-mi code tries to open a source buffer, 'gdb-display-source-buffer' is used. Also, we simply the logic in 'gdb-display-source-buffer' and add a feature to limit the maximum number of source windows. * lisp/progmodes/gdb-mi.el (gdb-source-window): Remove variable, change to 'gdb-source-window-list'. (gdb-source-window-list): New variable. (gdb-display-source-buffer-action, gdb-max-source-window-count): New custom variable. (gdb-init-1, gdb-setup-windows, gdb-save-window-configuration, gdb-load-window-configuration, gdb-restore-windows): Use 'gdb-source-window' rather than 'gdb-source-window-list'. (gdb-display-source-buffer): Use new logic. (gdb-goto-breakpoint): Remove 'display-buffer' and don't set 'gdb-source-buffer' anymore. * lisp/progmodes/gud.el (gud-display-line): If used by gdb-mi, use 'gdb-display-source-buffer' rather than 'display-buffer'. Don't set 'gdb-source-buffer' anymore. --- lisp/progmodes/gdb-mi.el | 73 +++++++++++++++++++++++++++++----------- lisp/progmodes/gud.el | 12 +++---- 2 files changed, 59 insertions(+), 26 deletions(-) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 7fb3687391..93012ad18d 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -224,7 +224,9 @@ gdb-handler-list (defvar gdb-source-file-list nil "List of source files for the current executable.") (defvar gdb-first-done-or-error t) -(defvar gdb-source-window nil) +(defvar gdb-source-window-list nil + "List of windows used for displaying source files. +Sorted in most recently visited first order.") (defvar gdb-inferior-status nil) (defvar gdb-continuation nil) (defvar gdb-supports-non-stop nil) @@ -645,6 +647,21 @@ gdb-default-window-configuration-file :group 'gdb :version "28.1") +(defcustom gdb-display-source-buffer-action '(nil . ((inhibit-same-window . t))) + "`display-buffer' action used when GDB displaying a source buffer." + :type 'list + :group 'gdb + :version "28.1") + +(defcustom gdb-max-source-window-count 1 + "Maximum number of source windows to use. +Until there are such number of source windows on screen, GDB +tries to open a new window when visiting a new source file; after +that GDB starts to reuse existing source windows." + :type 'number + :group 'gdb + :version "28.1") + (defvar gdbmi-debug-mode nil "When non-nil, print the messages sent/received from GDB/MI in *Messages*.") @@ -984,7 +1001,7 @@ gdb-init-1 gdb-first-done-or-error t gdb-buffer-fringe-width (car (window-fringes)) gdb-debug-log nil - gdb-source-window nil + gdb-source-window-list nil gdb-inferior-status nil gdb-continuation nil gdb-buf-publisher '() @@ -2069,17 +2086,35 @@ gdb-show-stop-p ;; GDB frame (after up, down etc). If no GDB frame is visible but the last ;; visited breakpoint is, use that window. (defun gdb-display-source-buffer (buffer) - (let* ((last-window (if gud-last-last-frame - (get-buffer-window - (gud-find-file (car gud-last-last-frame))))) - (source-window (or last-window - (if (and gdb-source-window - (window-live-p gdb-source-window)) - gdb-source-window)))) - (when source-window - (setq gdb-source-window source-window) - (set-window-buffer source-window buffer)) - source-window)) + "Find a window to display BUFFER. +Always find a window to display buffer, and return it." + ;; This function doesn't take care of setting up source window(s) at startup, + ;; that's handled by `gdb-setup-windows' (if `gdb-many-windows' is non-nil). + ;; If `buffer' is already shown in a window, use that window. + (or (get-buffer-window buffer) + (progn + ;; First, update the window list. + (setq gdb-source-window-list + (cl-remove-duplicates + (cl-remove-if-not (lambda (win) (and (window-live-p win) + (equal (window-frame win) + (selected-frame)))) + gdb-source-window-list) + :test #'equal)) + ;; Should we create a new window or reuse one? + (if (> gdb-max-source-window-count + (length gdb-source-window-list)) + ;; Create a new window, push it to window list and return it. + (car (push (display-buffer buffer gdb-display-source-buffer-action) + gdb-source-window-list)) + ;; Reuse a window, we use the oldest window and put that to + ;; the front of the window list. + (let ((last-win (car (last gdb-source-window-list))) + (rest (butlast gdb-source-window-list))) + (set-window-buffer last-win buffer) + (setq gdb-source-window-list + (cons last-win rest)) + last-win))))) (defun gdbmi-start-with (str offset match) @@ -4064,9 +4099,7 @@ gdb-goto-breakpoint (let* ((buffer (find-file-noselect (if (file-exists-p file) file (cdr (assoc bptno gdb-location-alist))))) - (window (or (gdb-display-source-buffer buffer) - (display-buffer buffer)))) - (setq gdb-source-window window) + (window (gdb-display-source-buffer buffer))) (with-current-buffer buffer (goto-char (point-min)) (forward-line (1- (string-to-number line))) @@ -4715,7 +4748,7 @@ gdb-setup-windows (select-window win2) (set-window-buffer win2 (or (gdb-get-source-buffer) (list-buffers-noselect))) - (setq gdb-source-window (selected-window)) + (setq gdb-source-window-list (list (selected-window))) (let ((win4 (split-window-right))) (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-inferior-io) nil win4)) @@ -4791,7 +4824,7 @@ gdb-save-window-configuration (error "Unrecognized gdb buffer mode: %s" major-mode))) ;; Command buffer. ((derived-mode-p 'gud-mode) 'command) - ((equal (selected-window) gdb-source-window) 'source))) + ((member (selected-window) gdb-source-window-list) 'source))) (with-window-non-dedicated nil (set-window-buffer nil placeholder) (set-window-prev-buffers (selected-window) nil) @@ -4834,7 +4867,7 @@ gdb-load-window-configuration (pcase buffer-type ('source (when source-buffer (set-window-buffer nil source-buffer) - (setq gdb-source-window (selected-window)))) + (push (selected-window) gdb-source-window-list))) ('command (switch-to-buffer gud-comint-buffer)) (_ (let ((buffer (gdb-get-buffer-create buffer-type))) (with-window-non-dedicated nil @@ -4875,7 +4908,7 @@ gdb-restore-windows (if gud-last-last-frame (gud-find-file (car gud-last-last-frame)) (gud-find-file gdb-main-file))) - (setq gdb-source-window win))))) + (setq gdb-source-window-list (list win)))))) ;; Called from `gud-sentinel' in gud.el: (defun gdb-reset () diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 567f452b93..c9522bfe17 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -2826,9 +2826,11 @@ gud-display-line (buffer (with-current-buffer gud-comint-buffer (gud-find-file true-file))) - (window (and buffer - (or (get-buffer-window buffer) - (display-buffer buffer '(nil (inhibit-same-window . t)))))) + (window (when buffer (if (eq gud-minor-mode 'gdbmi) + (gdb-display-source-buffer buffer) + ;; Gud still has the old behavior. + (or (get-buffer-window buffer) + (display-buffer buffer '(nil (inhibit-same-window . t))))))) (pos)) (when buffer (with-current-buffer buffer @@ -2858,9 +2860,7 @@ gud-display-line (widen) (goto-char pos)))) (when window - (set-window-point window gud-overlay-arrow-position) - (if (eq gud-minor-mode 'gdbmi) - (setq gdb-source-window window)))))) + (set-window-point window gud-overlay-arrow-position))))) ;; The gud-call function must do the right thing whether its invoking ;; keystroke is from the GUD buffer itself (via major-mode binding) -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-03-29 17:27 ` Yuan Fu @ 2020-03-31 9:15 ` martin rudalics 2020-04-04 20:29 ` Yuan Fu 0 siblings, 1 reply; 8+ messages in thread From: martin rudalics @ 2020-03-31 9:15 UTC (permalink / raw) To: Yuan Fu; +Cc: 40268 > This one should be ok. Thanks. A few remarks. Please try to ident as (setq gdb-source-window-list (cl-remove-duplicates (cl-remove-if-not (lambda (win) (and (window-live-p win) (equal (window-frame win) (selected-frame)))) gdb-source-window-list) :test #'equal)) so we can safely change this later and easily stay within our line length limits. Also, tests like (equal (window-frame win) (selected-frame)))) should use "eq" instead of "equal" and ones like ((member (selected-window) gdb-source-window-list) 'source))) "memq" instead of "member". Similarly to the above, writing (window (when buffer (if (eq gud-minor-mode 'gdbmi) (gdb-display-source-buffer buffer) ;; Gud still has the old behavior. (or (get-buffer-window buffer) (display-buffer buffer '(nil (inhibit-same-window . t))))))) permits us to stay within the 80 columns limit. Finally, instead of "Also, we simply the logic ..." I'd write "Also, simplify the logic ...". And please provide a NEWS entry. Thanks again for the work, martin ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-03-31 9:15 ` martin rudalics @ 2020-04-04 20:29 ` Yuan Fu 2020-04-06 9:04 ` martin rudalics 0 siblings, 1 reply; 8+ messages in thread From: Yuan Fu @ 2020-04-04 20:29 UTC (permalink / raw) To: martin rudalics; +Cc: 40268 [-- Attachment #1: Type: text/plain, Size: 1711 bytes --] > On Mar 31, 2020, at 5:15 AM, martin rudalics <rudalics@gmx.at> wrote: > > > This one should be ok. > > Thanks. A few remarks. Please try to ident as > > (setq gdb-source-window-list > (cl-remove-duplicates > (cl-remove-if-not > (lambda (win) > (and (window-live-p win) > (equal (window-frame win) > (selected-frame)))) > gdb-source-window-list) > :test #'equal)) > > so we can safely change this later and easily stay within our line > length limits. Also, tests like > > (equal (window-frame win) > (selected-frame)))) > > should use "eq" instead of "equal" and ones like > > ((member (selected-window) gdb-source-window-list) 'source))) > > "memq" instead of "member". > > Similarly to the above, writing > > (window > (when buffer > (if (eq gud-minor-mode 'gdbmi) > (gdb-display-source-buffer buffer) > ;; Gud still has the old behavior. > (or (get-buffer-window buffer) > (display-buffer buffer '(nil (inhibit-same-window . t))))))) > > permits us to stay within the 80 columns limit. > > Finally, instead of "Also, we simply the logic ..." I'd write "Also, > simplify the logic ...". And please provide a NEWS entry. > > Thanks again for the work, Martin Thanks for reviewing. Besides the changes you requested, I changed the last condition in the cond form in `gdb-save-window-configuration’ to a catch-all condition (to avoid weird problem when loading it back). Yuan [-- Attachment #2: source-window.patch --] [-- Type: application/octet-stream, Size: 11092 bytes --] From 41a8528515bbb9aeef6880ee3b7bc90320ab8b51 Mon Sep 17 00:00:00 2001 From: Yuan Fu <casouri@gmail.com> Date: Sun, 29 Mar 2020 10:20:53 -0400 Subject: [PATCH] Unify and improve gdb-mi source buffer display logic Unify the behavior of source buffer display for gdb-mi. Before this change, stepping and other gdb command handlers use 'gud-display-line', and 'gdb-goto-breakpoint' uses 'gdb-display-source-buffer'. Now whenever gdb-mi code tries to open a source buffer, 'gdb-display-source-buffer' is used. Also, simplify the logic in 'gdb-display-source-buffer' and add a feature to limit the maximum number of source windows. * doc/emacs/building.texi (GDB User Interface Layout): Explain source file display in GDB. * etc/NEWS (gdb-mi): Add news about source display. * lisp/progmodes/gdb-mi.el (gdb-source-window): Remove variable, change to 'gdb-source-window-list'. (gdb-source-window-list): New variable. (gdb-display-source-buffer-action, gdb-max-source-window-count): New custom variable. (gdb-init-1, gdb-setup-windows, gdb-load-window-configuration, gdb-restore-windows): Use 'gdb-source-window' rather than 'gdb-source-window-list'. (gdb-save-window-configuration): Use 'gdb-source-window' rather than 'gdb-source-window-list'. And consider any buffer that is not a command or function buffer as a source buffer. (gdb-display-source-buffer): Use new logic. (gdb-goto-breakpoint): Remove 'display-buffer' and don't set 'gdb-source-buffer' anymore. * lisp/progmodes/gud.el (gud-display-line): If used by gdb-mi, use 'gdb-display-source-buffer' rather than 'display-buffer'. Don't set 'gdb-source-buffer' anymore. --- doc/emacs/building.texi | 8 +++++ etc/NEWS | 6 ++++ lisp/progmodes/gdb-mi.el | 75 +++++++++++++++++++++++++++++----------- lisp/progmodes/gud.el | 14 ++++---- 4 files changed, 77 insertions(+), 26 deletions(-) diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index 8a05680c74..2c43323dc4 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi @@ -1022,6 +1022,14 @@ GDB User Interface Layout the same with the menu bar, with the @samp{GDB-Windows} and @samp{GDB-Frames} sub-menus of the @samp{GUD} menu. +@vindex gdb-max-source-window-count +@vindex gdb-display-source-buffer-action +By default, GDB uses at most one window to display source file. You +can make it use more windows by customizing +@code{gdb-max-source-window-count}. You can also customize +@code{gdb-display-source-buffer-action} to control how does GDB +display source files. + When you finish debugging, kill the GUD interaction buffer with @kbd{C-x k}, which will also kill all the buffers associated with the session. However you need not do this if, after editing and diff --git a/etc/NEWS b/etc/NEWS index 4b477e5def..1260dfa30c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -213,6 +213,12 @@ will remember the window configuration before GDB started and restore it after GDB quits. A toggle button is also provided under 'Gud -- GDB-Windows'. +--- +*** gdb-mi now has a better logic for displaying source buffers +Now GDB only uses one source window to display source file by default. +Customize 'gdb-max-source-window-count' to use more than one windows. +Control source file display by 'gdb-display-source-buffer-action'. + ** Gravatar --- diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 7fb3687391..d513c7606d 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -224,7 +224,9 @@ gdb-handler-list (defvar gdb-source-file-list nil "List of source files for the current executable.") (defvar gdb-first-done-or-error t) -(defvar gdb-source-window nil) +(defvar gdb-source-window-list nil + "List of windows used for displaying source files. +Sorted in most-recently-visited-first order.") (defvar gdb-inferior-status nil) (defvar gdb-continuation nil) (defvar gdb-supports-non-stop nil) @@ -645,6 +647,21 @@ gdb-default-window-configuration-file :group 'gdb :version "28.1") +(defcustom gdb-display-source-buffer-action '(nil . ((inhibit-same-window . t))) + "`display-buffer' action used when GDB displaying a source buffer." + :type 'list + :group 'gdb + :version "28.1") + +(defcustom gdb-max-source-window-count 1 + "Maximum number of source windows to use. +Until there are such number of source windows on screen, GDB +tries to open a new window when visiting a new source file; after +that GDB starts to reuse existing source windows." + :type 'number + :group 'gdb + :version "28.1") + (defvar gdbmi-debug-mode nil "When non-nil, print the messages sent/received from GDB/MI in *Messages*.") @@ -984,7 +1001,7 @@ gdb-init-1 gdb-first-done-or-error t gdb-buffer-fringe-width (car (window-fringes)) gdb-debug-log nil - gdb-source-window nil + gdb-source-window-list nil gdb-inferior-status nil gdb-continuation nil gdb-buf-publisher '() @@ -2069,17 +2086,36 @@ gdb-show-stop-p ;; GDB frame (after up, down etc). If no GDB frame is visible but the last ;; visited breakpoint is, use that window. (defun gdb-display-source-buffer (buffer) - (let* ((last-window (if gud-last-last-frame - (get-buffer-window - (gud-find-file (car gud-last-last-frame))))) - (source-window (or last-window - (if (and gdb-source-window - (window-live-p gdb-source-window)) - gdb-source-window)))) - (when source-window - (setq gdb-source-window source-window) - (set-window-buffer source-window buffer)) - source-window)) + "Find a window to display BUFFER. +Always find a window to display buffer, and return it." + ;; This function doesn't take care of setting up source window(s) at startup, + ;; that's handled by `gdb-setup-windows' (if `gdb-many-windows' is non-nil). + ;; If `buffer' is already shown in a window, use that window. + (or (get-buffer-window buffer) + (progn + ;; First, update the window list. + (setq gdb-source-window-list + (cl-remove-duplicates + (cl-remove-if-not + (lambda (win) + (and (window-live-p win) + (eq (window-frame win) + (selected-frame)))) + gdb-source-window-list))) + ;; Should we create a new window or reuse one? + (if (> gdb-max-source-window-count + (length gdb-source-window-list)) + ;; Create a new window, push it to window list and return it. + (car (push (display-buffer buffer gdb-display-source-buffer-action) + gdb-source-window-list)) + ;; Reuse a window, we use the oldest window and put that to + ;; the front of the window list. + (let ((last-win (car (last gdb-source-window-list))) + (rest (butlast gdb-source-window-list))) + (set-window-buffer last-win buffer) + (setq gdb-source-window-list + (cons last-win rest)) + last-win))))) (defun gdbmi-start-with (str offset match) @@ -4064,9 +4100,7 @@ gdb-goto-breakpoint (let* ((buffer (find-file-noselect (if (file-exists-p file) file (cdr (assoc bptno gdb-location-alist))))) - (window (or (gdb-display-source-buffer buffer) - (display-buffer buffer)))) - (setq gdb-source-window window) + (window (gdb-display-source-buffer buffer))) (with-current-buffer buffer (goto-char (point-min)) (forward-line (1- (string-to-number line))) @@ -4715,7 +4749,7 @@ gdb-setup-windows (select-window win2) (set-window-buffer win2 (or (gdb-get-source-buffer) (list-buffers-noselect))) - (setq gdb-source-window (selected-window)) + (setq gdb-source-window-list (list (selected-window))) (let ((win4 (split-window-right))) (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-inferior-io) nil win4)) @@ -4791,7 +4825,8 @@ gdb-save-window-configuration (error "Unrecognized gdb buffer mode: %s" major-mode))) ;; Command buffer. ((derived-mode-p 'gud-mode) 'command) - ((equal (selected-window) gdb-source-window) 'source))) + ;; Consider everything else as source buffer. + (t 'source))) (with-window-non-dedicated nil (set-window-buffer nil placeholder) (set-window-prev-buffers (selected-window) nil) @@ -4834,7 +4869,7 @@ gdb-load-window-configuration (pcase buffer-type ('source (when source-buffer (set-window-buffer nil source-buffer) - (setq gdb-source-window (selected-window)))) + (push (selected-window) gdb-source-window-list))) ('command (switch-to-buffer gud-comint-buffer)) (_ (let ((buffer (gdb-get-buffer-create buffer-type))) (with-window-non-dedicated nil @@ -4875,7 +4910,7 @@ gdb-restore-windows (if gud-last-last-frame (gud-find-file (car gud-last-last-frame)) (gud-find-file gdb-main-file))) - (setq gdb-source-window win))))) + (setq gdb-source-window-list (list win)))))) ;; Called from `gud-sentinel' in gud.el: (defun gdb-reset () diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 567f452b93..eb43e8b7e4 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -2826,9 +2826,13 @@ gud-display-line (buffer (with-current-buffer gud-comint-buffer (gud-find-file true-file))) - (window (and buffer - (or (get-buffer-window buffer) - (display-buffer buffer '(nil (inhibit-same-window . t)))))) + (window + (when buffer + (if (eq gud-minor-mode 'gdbmi) + (gdb-display-source-buffer buffer) + ;; Gud still has the old behavior. + (or (get-buffer-window buffer) + (display-buffer buffer '(nil (inhibit-same-window . t))))))) (pos)) (when buffer (with-current-buffer buffer @@ -2858,9 +2862,7 @@ gud-display-line (widen) (goto-char pos)))) (when window - (set-window-point window gud-overlay-arrow-position) - (if (eq gud-minor-mode 'gdbmi) - (setq gdb-source-window window)))))) + (set-window-point window gud-overlay-arrow-position))))) ;; The gud-call function must do the right thing whether its invoking ;; keystroke is from the GUD buffer itself (via major-mode binding) -- 2.25.1 [-- Attachment #3: Type: text/plain, Size: 1 bytes --] ^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-04-04 20:29 ` Yuan Fu @ 2020-04-06 9:04 ` martin rudalics 2020-04-06 14:21 ` Yuan Fu 0 siblings, 1 reply; 8+ messages in thread From: martin rudalics @ 2020-04-06 9:04 UTC (permalink / raw) To: Yuan Fu; +Cc: 40268 > Thanks for reviewing. Besides the changes you requested, I changed the > last condition in the cond form in `gdb-save-window-configuration’ to > a catch-all condition (to avoid weird problem when loading it back). Pushed to master with my usual tweaks. Please have a look. Thanks, martin ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-04-06 9:04 ` martin rudalics @ 2020-04-06 14:21 ` Yuan Fu 0 siblings, 0 replies; 8+ messages in thread From: Yuan Fu @ 2020-04-06 14:21 UTC (permalink / raw) To: martin rudalics; +Cc: 40268 > On Apr 6, 2020, at 5:04 AM, martin rudalics <rudalics@gmx.at> wrote: > > > Thanks for reviewing. Besides the changes you requested, I changed the > > last condition in the cond form in `gdb-save-window-configuration’ to > > a catch-all condition (to avoid weird problem when loading it back). > > Pushed to master with my usual tweaks. Please have a look. > > Thanks, martin > Thanks, I’ll try to address them next time. Yuan ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#40268: Fwd: bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display 2020-03-28 4:03 ` bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display Yuan Fu 2020-03-29 9:01 ` martin rudalics @ 2020-04-14 1:09 ` Yuan Fu 1 sibling, 0 replies; 8+ messages in thread From: Yuan Fu @ 2020-04-14 1:09 UTC (permalink / raw) To: 40268-done [-- Attachment #1: Type: text/plain, Size: 477 bytes --] > Begin forwarded message: > > From: martin rudalics <rudalics@gmx.at> > Subject: Re: bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display > Date: April 13, 2020 at 1:29:00 PM GMT-4 > To: Yuan Fu <casouri@gmail.com> > >> Thanks, I’ll try to address them next time. >> Yuan > > Please consider marking this and maybe some other bug (Bug#39181?) > as done unless we should change something else too. > > Thanks, martin > > > [-- Attachment #2: Type: text/html, Size: 2561 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-04-14 1:09 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <310914cd-1822-3fe9-19ae-6e47f8e72072@gmx.at> 2020-03-28 4:03 ` bug#40268: 27.0.60; [PATCH] Unify and improve gdb-mi source window display Yuan Fu 2020-03-29 9:01 ` martin rudalics 2020-03-29 17:27 ` Yuan Fu 2020-03-31 9:15 ` martin rudalics 2020-04-04 20:29 ` Yuan Fu 2020-04-06 9:04 ` martin rudalics 2020-04-06 14:21 ` Yuan Fu 2020-04-14 1:09 ` bug#40268: Fwd: " Yuan Fu
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).