stan-dev / stan-mode

Emacs mode for Stan.
GNU General Public License v3.0
71 stars 15 forks source link

emacs hangs on certain files #69

Open grburgess opened 2 years ago

grburgess commented 2 years ago

Hi, I have encountered a strange error on opening certain files. Emacs will completely freeze up (cpu 99%) when opening certain files. I'm not really sure what the difference between files that work and do not work, but I've attached the output from the debugger:

* substitute-command-keys("Quit")
  c-forward-decl-or-cast-1(3098 arglist nil)
  #f(compiled-function (match-pos inside-macro &optional toplev) #<bytecode -0xdbad6147da63c60>)(3098 nil t)
  c-find-decl-spots(3129 "[[:alpha:]]" nil #f(compiled-function (match-pos inside-macro &optional toplev) #<bytecode -0xdbad6147da63c60>))
  c-find-types-background(2021 3129)
  c-type-finder-timer-func()
  apply(c-type-finder-timer-func nil)
  timer-event-handler([t 25032 1614 700213 nil c-type-finder-timer-func nil nil 0 nil])

I have also attached the file which caused this error:

functions {
#include absori.stan
#include tbabs.stan
#include powerlaw.stan
#include cstat.stan
#include partial_log_like.stan
}

data{

  int N_grbs;
  int N_ene;
  int N_chan;
  matrix[N_chan, N_ene] rsp[N_grbs];
  vector[N_grbs] z; //redshift
  vector[N_grbs] nH_mw;
  vector[N_ene] precomputed_absorp[N_grbs];
  vector[N_ene] host_precomputed_absorp[N_grbs];
  vector[N_grbs] exposure_ratio;
  vector[N_ene] ene_avg[N_grbs];
  vector[N_ene] ene_width[N_grbs];
  int n_chans_used[N_grbs];
  vector[N_chan] counts[N_grbs];
  vector[N_chan] bkg[N_grbs];
  int mask[N_grbs,N_chan];
  vector[N_grbs] exposure;

  // absori input
  real xi;
  int atomicnumber[10];
  real ion[10,26,10];
  real sigma[10,26,721];
  vector[721] spec;
  vector[10] abundance;
  matrix[10,26] sum_sigma_interp[N_grbs, N_ene];
}

transformed data{
  int all_N[N_grbs];
  int grainsize = 1;

  //mw abs is fixed
  vector[N_ene] mw_abs[N_grbs];

  for (n in 1:N_grbs){
    mw_abs[n] = absorption(nH_mw[n], precomputed_absorp[n]);
  }

  // precalculation of energy bounds

  for (n in 1:N_grbs) {

    all_N[n] = n;

  }
}

parameters{

  //vector<upper=0>[N_grbs] index;
  real log_nH_host_mu_raw;
  real<upper=0> host_alpha; // skew normal paramter

  real<lower=0> log_nH_host_sigma;
  vector[N_grbs] log_nH_host_raw;

  real index_mu;
  real<lower=0> index_sigma;
  vector[N_grbs] index_raw;

  real log_K_mu_raw;
  real<lower=0> log_K_sigma;

  vector[N_grbs] log_K_raw; // raw energy flux norm

  // absori parameter
  real log_n0_whim_raw;
  real<upper=8> log_t_whim;
}

transformed parameters{
  vector[N_grbs] index;
  vector[N_grbs] log_K; // log eflux
  vector[N_grbs] K;
  vector[N_grbs] log_nH_host;
  //  vector[N_grbs] nH_host;
  vector[N_grbs] nH_host_norm;

  real log_n0_whim = log_n0_whim_raw -7;

  real log_K_mu = log_K_mu_raw - 9;

  // absori
  real n0_whim = pow(10, log_n0_whim);

  // free temp
  matrix[10,26] num;
  real t_whim=pow(10,log_t_whim);

  num = calc_num(spec, t_whim, xi, atomicnumber, sigma, ion);
  for (i in 1:10){
    num[i] = abundance[i]*num[i];
  }

  // non centered parameterizartion

  log_nH_host = log_nH_host_mu_raw + log_nH_host_raw * log_nH_host_sigma;

  index = index_mu + index_raw * index_sigma;

  log_K = log_K_mu + log_K_raw * log_K_sigma;

  K =  pow(10.,log_K);

  nH_host_norm = pow(10.,log_nH_host);

}

model{

  host_alpha ~ normal(-2,1);

  index_raw ~ std_normal();
  log_K_raw ~ std_normal();
  log_nH_host_raw ~ std_normal();

  //log_nH_host_mu_raw ~ skew_normal(0,1, host_alpha);

  log_nH_host_raw ~ normal(0,1);

  target += normal_lcdf(host_alpha * log_nH_host_raw | 0, 1);

  log_nH_host_sigma ~ std_normal();

  log_K_mu_raw ~ std_normal();
  log_K_sigma ~ std_normal();

  index_mu ~ normal(-2, .1);
  index_sigma ~ std_normal();

  //absori

  log_n0_whim_raw ~ normal(0, 2);

  log_t_whim ~ normal(6, 2);

  target += reduce_sum(partial_log_like_all, all_N, grainsize, N_ene, N_chan, ene_avg, ene_width, mask, n_chans_used, mw_abs, K, index, n0_whim, num, sum_sigma_interp, nH_host_norm, host_precomputed_absorp, rsp, exposure, exposure_ratio, counts, bkg);

}

generated quantities {

}

GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin21.1.0, NS appkit-2113.00 Version 12.0.1 (Build 21A559)) of 2021-11-19

Stan-mode is from the master branch.

Thanks!

WardBrian commented 2 years ago

I'm unable to recreate this locally (Emacs 27 on Ubuntu 20.04) with your provided file. Do you have a complete list of active packages?

grburgess commented 2 years ago

I am attaching the output from describe mode:

Enabled minor modes: All-The-Icons-Completion Auto-Composition Auto-Compression
Auto-Encryption Beacon Blink-Cursor Column-Number Company Display-Line-Numbers
Doom-Modeline Eldoc Electric-Indent Emojify Eshell-Syntax-Highlighting-Global
File-Name-Shadow Flycheck Font-Lock Git-Gutter Global-Auto-Revert Global-Company
Global-Display-Line-Numbers Global-Eldoc Global-Emojify Global-Font-Lock
Global-Git-Commit Highlight-Indent-Guides Indent-Tabs Line-Number Marginalia
Menu-Bar Minions Mouse-Wheel Omni Override-Global Projectile Pyvenv
Pyvenv-Tracking Rainbow Rainbow-Delimiters Savehist Shell-Dirtrack Show-Paren
Smartparens Straight-Package-Neutering Straight-Use-Package Sublimity
Transient-Mark Treemacs-Filewatch Treemacs-Follow Treemacs-Fringe-Indicator
Treemacs-Git Vertico Which-Key Windmove Ws-Butler Yas

(Information about these minor modes follows the major mode info.)

Stan/*l mode defined in ‘stan-mode.el’:
A major mode for editing Stan files.

The hook ‘c-mode-common-hook’ is run with no args at mode
initialization, then ‘stan-mode-hook’.

Key bindings:
key             binding
---             -------

C-c     Prefix Command
C-d     c-electric-delete-forward
TAB     c-indent-line-or-region
ESC     Prefix Command
#       c-electric-pound
( .. )      c-electric-paren
*       c-electric-star
,       c-electric-semi&comma
/       c-electric-slash
:       c-electric-colon
;       c-electric-semi&comma
{       c-electric-brace
}       c-electric-brace
DEL     c-electric-backspace

C-M-a       stan-beginning-of-block
C-M-e       stan-end-of-block
C-M-h       stan-mark-block
M-a     stan-beginning-of-statement
M-e     stan-end-of-statement

C-c C-a     c-toggle-auto-newline
C-c C-b     c-submit-bug-report
C-c C-c     comment-region
C-c C-d     c-hungry-delete-forward
C-c C-k     c-toggle-comment-style
C-c C-l     c-toggle-electric-state
C-c C-n     c-forward-conditional
C-c C-o     c-set-offset
C-c C-p     c-backward-conditional
C-c C-q     c-indent-defun
C-c C-s     c-show-syntactic-information
C-c C-u     c-up-conditional
C-c C-w     c-subword-mode
C-c C-z     c-display-defun-name
C-c C-\     c-backslash-region
C-c .       c-set-style
C-c DEL     c-hungry-delete-backwards
C-c C-DEL   c-hungry-delete-backwards
C-c C-<backspace>       c-hungry-delete-backwards
C-c C-<delete>          c-hungry-delete-forward
C-c C-<deletechar>      c-hungry-delete-forward
C-c <deletechar>        c-hungry-delete-forward

C-M-a       c-beginning-of-defun
  (this binding is currently shadowed)
C-M-e       c-end-of-defun
  (this binding is currently shadowed)
C-M-h       c-mark-function
  (this binding is currently shadowed)
C-M-q       c-indent-exp
M-a     c-beginning-of-statement
  (this binding is currently shadowed)
M-e     c-end-of-statement
  (this binding is currently shadowed)
M-q     c-fill-paragraph

C-M-q       prog-indent-sexp
  (this binding is currently shadowed)


All-The-Icons-Completion minor mode (no indicator):
Add icons to completion candidates.

This is a minor mode.  If called interactively, toggle the
‘All-The-Icons-Completion mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'all-the-icons-completion-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Auto-Composition minor mode (no indicator):
Toggle Auto Composition mode.

This is a minor mode.  If called interactively, toggle the
‘Auto-Composition mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘auto-composition-mode’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

When Auto Composition mode is enabled, text characters are
automatically composed by functions registered in
‘composition-function-table’.

You can use ‘global-auto-composition-mode’ to turn on
Auto Composition mode in all buffers (this is the default).

Auto-Compression minor mode (no indicator):
Toggle Auto Compression mode.

This is a minor mode.  If called interactively, toggle the
‘Auto-Compression mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'auto-compression-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Auto Compression mode is a global minor mode.  When enabled,
compressed files are automatically uncompressed for reading, and
compressed when writing.

Auto-Encryption minor mode (no indicator):
Toggle automatic file encryption/decryption (Auto Encryption mode).

This is a minor mode.  If called interactively, toggle the
‘Auto-Encryption mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'auto-encryption-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Beacon minor mode (indicator (*)):
Toggle Beacon mode on or off.

This is a minor mode.  If called interactively, toggle the
‘Beacon mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'beacon-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Uses keymap ‘beacon-mode-map’, which is not currently defined.


Blink-Cursor minor mode (no indicator):
Toggle cursor blinking (Blink Cursor mode).

This is a minor mode.  If called interactively, toggle the
‘Blink-Cursor mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'blink-cursor-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

If the value of ‘blink-cursor-blinks’ is positive (10 by default),
the cursor stops blinking after that number of blinks, if Emacs
gets no input during that time.

See also ‘blink-cursor-interval’ and ‘blink-cursor-delay’.

This command is effective only on graphical frames.  On text-only
terminals, cursor blinking is controlled by the terminal.

Column-Number minor mode (no indicator):
Toggle column number display in the mode line (Column Number mode).

This is a minor mode.  If called interactively, toggle the
‘Column-Number mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'column-number-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

See ‘mode-line-position-column-format’ for how this number is
presented.

Company minor mode (indicator company):
"complete anything"; is an in-buffer completion framework.
Completion starts automatically, depending on the values
‘company-idle-delay’ and ‘company-minimum-prefix-length’.

This is a minor mode.  If called interactively, toggle the
‘Company mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘company-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Completion can be controlled with the commands:
‘company-complete-common’, ‘company-complete-selection’, ‘company-complete’,
‘company-select-next’, ‘company-select-previous’.  If these commands are
called before ‘company-idle-delay’, completion will also start.

Completions can be searched with ‘company-search-candidates’ or
‘company-filter-candidates’.  These can be used while completion is
inactive, as well.

The completion data is retrieved using ‘company-backends’ and displayed
using ‘company-frontends’.  If you want to start a specific backend, call
it interactively or use ‘company-begin-backend’.

By default, the completions list is sorted alphabetically, unless the
backend chooses otherwise, or ‘company-transformers’ changes it later.

regular keymap (‘company-mode-map’):

key             binding
---             -------

keymap during active completions (‘company-active-map’):

key             binding
---             -------

C-g     company-abort
C-h     company-show-doc-buffer
TAB     company-complete-common
RET     company-complete-selection
C-n     company-select-next
C-p     company-select-previous
C-s     company-search-candidates
C-w     company-show-location
ESC     Prefix Command
<down>      company-select-next-or-abort
<down-mouse-1>  ignore
<down-mouse-3>  ignore
<f1>        company-show-doc-buffer
<mouse-1>   company-complete-mouse
<mouse-3>   company-select-mouse
<remap>     Prefix Command
<return>    company-complete-selection
<tab>       company-complete-common
<up>        company-select-previous-or-abort
<up-mouse-1>    ignore
<up-mouse-3>    ignore

<remap> <scroll-down-command>   company-previous-page
<remap> <scroll-up-command> company-next-page

C-M-s       company-filter-candidates
ESC ESC     Prefix Command
M-0 .. M-9  company-complete-quick-access
M-n     company--select-next-and-warn
M-p     company--select-previous-and-warn

M-ESC ESC   company-abort


Display-Line-Numbers minor mode (no indicator):
Toggle display of line numbers in the buffer.
This uses ‘display-line-numbers’ internally.

This is a minor mode.  If called interactively, toggle the
‘Display-Line-Numbers mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘display-line-numbers-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

To change the type of line numbers displayed by default,
customize ‘display-line-numbers-type’.  To change the type while
the mode is on, set ‘display-line-numbers’ directly.

Doom-Modeline minor mode (no indicator):
Toggle doom-modeline on or off.

This is a minor mode.  If called interactively, toggle the
‘Doom-Modeline mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'doom-modeline-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Eldoc minor mode (indicator ElDoc):
Toggle echo area display of Lisp objects at point (ElDoc mode).

This is a minor mode.  If called interactively, toggle the ‘Eldoc
mode’ mode.  If the prefix argument is positive, enable the mode, and
if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘eldoc-mode’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

ElDoc mode is a buffer-local minor mode.  When enabled, the echo
area displays information about a function or variable in the
text where point is.  If point is on a documented variable, it
displays the first line of that variable’s doc string.  Otherwise
it displays the argument list of the function called in the
expression point is on.

Electric-Indent minor mode (no indicator):
Toggle on-the-fly reindentation (Electric Indent mode).

This is a minor mode.  If called interactively, toggle the
‘Electric-Indent mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'electric-indent-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

When enabled, this reindents whenever the hook ‘electric-indent-functions’
returns non-nil, or if you insert a character from ‘electric-indent-chars’.

This is a global minor mode.  To toggle the mode in a single buffer,
use ‘electric-indent-local-mode’.

Emojify minor mode (no indicator):
Emojify mode

This is a minor mode.  If called interactively, toggle the
‘Emojify mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘emojify-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Eshell-Syntax-Highlighting-Global minor mode (no indicator):
Toggle Eshell-Syntax-Highlighting mode in all buffers.
With prefix ARG, enable Eshell-Syntax-Highlighting-Global mode if ARG
is positive; otherwise, disable it.

If called from Lisp, toggle the mode if ARG is ‘toggle’.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Eshell-Syntax-Highlighting mode is enabled in all buffers where
‘eshell-syntax-highlighting--global-on’ would do it.

See ‘eshell-syntax-highlighting-mode’ for more information on
Eshell-Syntax-Highlighting mode.

File-Name-Shadow minor mode (no indicator):
Toggle file-name shadowing in minibuffers (File-Name Shadow mode).

This is a minor mode.  If called interactively, toggle the
‘File-Name-Shadow mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'file-name-shadow-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

File-Name Shadow mode is a global minor mode.  When enabled, any
part of a filename being read in the minibuffer that would be
ignored (because the result is passed through
‘substitute-in-file-name’) is given the properties in
‘file-name-shadow-properties’, which can be used to make that
portion dim, invisible, or otherwise less visually noticeable.

Flycheck minor mode (indicator FlyC-):
Flycheck is a minor mode for on-the-fly syntax checking.

In ‘flycheck-mode’ the buffer is automatically syntax-checked
using the first suitable syntax checker from ‘flycheck-checkers’.
Use ‘flycheck-select-checker’ to select a checker for the current
buffer manually.

If you run into issues, use ‘M-x flycheck-verify-setup’ to get help.

Flycheck supports many languages out of the box, and many
additional ones are available on MELPA.  Adding new ones is very
easy.  Complete documentation is available online at URL
‘https://www.flycheck.org/en/latest/’.  Please report issues and
request features at URL ‘https://github.com/flycheck/flycheck’.

Flycheck displays its status in the mode line.  In the default
configuration, it looks like this:

‘FlyC’     This buffer has not been checked yet.
‘FlyC-’    Flycheck doesn’t have a checker for this buffer.
‘FlyC*’    Flycheck is running.  Expect results soon!
‘FlyC:3|2’ This buffer contains three warnings and two errors.
           Use ‘M-x flycheck-list-errors’ to see the list.

You may also see the following icons:
‘FlyC!’    The checker crashed.
‘FlyC.’    The last syntax check was manually interrupted.
‘FlyC?’    The checker did something unexpected, like exiting with 1
           but returning no errors.

The following keybindings are available in ‘flycheck-mode’:

key             binding
---             -------

C-c     Prefix Command

C-c !       Prefix Command

C-c ! C-c   flycheck-compile
C-c ! C-w   flycheck-copy-errors-as-kill
C-c ! ?     flycheck-describe-checker
C-c ! C     flycheck-clear
C-c ! H     display-local-help
C-c ! V     flycheck-version
C-c ! c     flycheck-buffer
C-c ! e     flycheck-explain-error-at-point
C-c ! h     flycheck-display-error-at-point
C-c ! i     flycheck-manual
C-c ! l     flycheck-list-errors
C-c ! n     flycheck-next-error
C-c ! p     flycheck-previous-error
C-c ! s     flycheck-select-checker
C-c ! v     flycheck-verify-setup
C-c ! x     flycheck-disable-checker

(you can change the prefix by customizing
‘flycheck-keymap-prefix’)

If called interactively, enable Flycheck mode if ARG is positive,
and disable it if ARG is zero or negative.  If called from Lisp,
also enable the mode if ARG is omitted or nil, and toggle it if
ARG is ‘toggle’; disable the mode otherwise.

Font-Lock minor mode (no indicator):
Toggle syntax highlighting in this buffer (Font Lock mode).

This is a minor mode.  If called interactively, toggle the ‘Font-Lock
mode’ mode.  If the prefix argument is positive, enable the mode, and
if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘font-lock-mode’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

When Font Lock mode is enabled, text is fontified as you type it:

 - Comments are displayed in ‘font-lock-comment-face’;
 - Strings are displayed in ‘font-lock-string-face’;
 - Certain other expressions are displayed in other faces
   according to the value of the variable ‘font-lock-keywords’.

To customize the faces (colors, fonts, etc.) used by Font Lock for
fontifying different parts of buffer text, use M-x customize-face.

You can enable Font Lock mode in any major mode automatically by
turning on in the major mode’s hook.  For example, put in your
~/.emacs:

 (add-hook 'c-mode-hook 'turn-on-font-lock)

Alternatively, you can use Global Font Lock mode to automagically
turn on Font Lock mode in buffers whose major mode supports it
and whose major mode is one of ‘font-lock-global-modes’.  For
example, put in your ~/.emacs:

 (global-font-lock-mode t)

Where major modes support different levels of fontification, you
can use the variable ‘font-lock-maximum-decoration’ to specify
which level you generally prefer.  When you turn Font Lock mode
on/off the buffer is fontified/defontified, though fontification
occurs only if the buffer is less than ‘font-lock-maximum-size’.

To add your own highlighting for some major mode, and modify the
highlighting selected automatically via the variable
‘font-lock-maximum-decoration’, you can use
‘font-lock-add-keywords’.

To fontify a buffer, without turning on Font Lock mode and
regardless of buffer size, you can use M-x font-lock-fontify-buffer.

To fontify a block (the function or paragraph containing point,
or a number of lines around point), perhaps because modification
on the current line caused syntactic change on other lines, you
can use M-x font-lock-fontify-block.

You can set your own default settings for some mode, by setting a
buffer local value for ‘font-lock-defaults’, via its mode hook.

The above is the default behavior of ‘font-lock-mode’; you may
specify your own function which is called when ‘font-lock-mode’
is toggled via ‘font-lock-function’.

Git-Gutter minor mode (no indicator):
Git-Gutter mode

This is a minor mode.  If called interactively, toggle the ‘Git-Gutter
mode’ mode.  If the prefix argument is positive, enable the mode, and
if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘git-gutter-mode’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Global-Auto-Revert minor mode (no indicator):
Toggle Global Auto-Revert Mode.

This is a minor mode.  If called interactively, toggle the
‘Global Auto-Revert mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'global-auto-revert-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Global Auto-Revert Mode is a global minor mode that reverts any
buffer associated with a file when the file changes on disk.  Use
‘auto-revert-mode’ to revert a particular buffer.

If ‘global-auto-revert-non-file-buffers’ is non-nil, this mode
may also revert some non-file buffers, as described in the
documentation of that variable.  It ignores buffers with modes
matching ‘global-auto-revert-ignore-modes’, and buffers with a
non-nil value of ‘global-auto-revert-ignore-buffer’.

When a buffer is reverted, a message is generated.  This can be
suppressed by setting ‘auto-revert-verbose’ to nil.

This function calls the hook ‘global-auto-revert-mode-hook’.
It displays the text that ‘global-auto-revert-mode-text’
specifies in the mode line.

Global-Company minor mode (no indicator):
Toggle Company mode in all buffers.
With prefix ARG, enable Global Company mode if ARG is positive;
otherwise, disable it.

If called from Lisp, toggle the mode if ARG is ‘toggle’.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Company mode is enabled in all buffers where ‘company-mode-on’ would
do it.

See ‘company-mode’ for more information on Company mode.

Global-Display-Line-Numbers minor mode (no indicator):
Toggle Display-Line-Numbers mode in all buffers.
With prefix ARG, enable Global Display-Line-Numbers mode if ARG is
positive; otherwise, disable it.

If called from Lisp, toggle the mode if ARG is ‘toggle’.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Display-Line-Numbers mode is enabled in all buffers where
‘display-line-numbers--turn-on’ would do it.

See ‘display-line-numbers-mode’ for more information on
Display-Line-Numbers mode.

Global-Eldoc minor mode (no indicator):
Toggle Eldoc mode in all buffers.
With prefix ARG, enable Global Eldoc mode if ARG is positive;
otherwise, disable it.

If called from Lisp, toggle the mode if ARG is ‘toggle’.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Eldoc mode is enabled in all buffers where ‘turn-on-eldoc-mode’ would
do it.

See ‘eldoc-mode’ for more information on Eldoc mode.

Global-Emojify minor mode (no indicator):
Toggle Emojify mode in all buffers.
With prefix ARG, enable Global Emojify mode if ARG is positive;
otherwise, disable it.

If called from Lisp, toggle the mode if ARG is ‘toggle’.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Emojify mode is enabled in all buffers where ‘emojify-mode’ would do
it.

See ‘emojify-mode’ for more information on Emojify mode.

Global-Font-Lock minor mode (no indicator):
Toggle Font-Lock mode in all buffers.
With prefix ARG, enable Global Font-Lock mode if ARG is positive;
otherwise, disable it.

If called from Lisp, toggle the mode if ARG is ‘toggle’.
Enable the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

Font-Lock mode is enabled in all buffers where
‘turn-on-font-lock-if-desired’ would do it.

See ‘font-lock-mode’ for more information on Font-Lock mode.

Global-Git-Commit minor mode (no indicator):
Edit Git commit messages.

This is a minor mode.  If called interactively, toggle the
‘Global Git-Commit mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'global-git-commit-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

This global mode arranges for ‘git-commit-setup’ to be called
when a Git commit message file is opened.  That usually happens
when Git uses the Emacsclient as $GIT_EDITOR to have the user
provide such a commit message.

Loading the library ‘git-commit’ by default enables this mode,
but the library is not automatically loaded because doing that
would pull in many dependencies and increase startup time too
much.  You can either rely on ‘magit’ loading this library or
you can load it explicitly.  Autoloading is not an alternative
because in this case autoloading would immediately trigger
full loading.

Highlight-Indent-Guides minor mode (indicator h-i-g):
Display indent guides in a buffer.

This is a minor mode.  If called interactively, toggle the
‘Highlight-Indent-Guides mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘highlight-indent-guides-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Indent-Tabs minor mode (no indicator):
Toggle whether indentation can insert TAB characters.

This is a minor mode.  If called interactively, toggle the
‘Indent-Tabs mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘indent-tabs-mode’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Line-Number minor mode (no indicator):
Toggle line number display in the mode line (Line Number mode).

This is a minor mode.  If called interactively, toggle the
‘Line-Number mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'line-number-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Line numbers do not appear for very large buffers and buffers
with very long lines; see variables ‘line-number-display-limit’
and ‘line-number-display-limit-width’.

See ‘mode-line-position-line-format’ for how this number is
presented.

Marginalia minor mode (no indicator):
Annotate completion candidates with richer information.

This is a minor mode.  If called interactively, toggle the
‘Marginalia mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'marginalia-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Menu-Bar minor mode (no indicator):
Toggle display of a menu bar on each frame (Menu Bar mode).

This is a minor mode.  If called interactively, toggle the ‘Menu-Bar
mode’ mode.  If the prefix argument is positive, enable the mode, and
if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘menu-bar-mode’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

This command applies to all frames that exist and frames to be
created in the future.

Minions minor mode (no indicator):
Display a minor-mode menu in the mode line.

This is a minor mode.  If called interactively, toggle the
‘Minions mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'minions-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

This replaces the likely incomplete and possibly cut off list of
minor-modes that is usually displayed directly in the mode line.

Mouse-Wheel minor mode (no indicator):
Toggle mouse wheel support (Mouse Wheel mode).

This is a minor mode.  If called interactively, toggle the
‘Mouse-Wheel mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'mouse-wheel-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Omni minor mode (no indicator):
Enable styles for selected window

This is a minor mode.  If called interactively, toggle the ‘Omni
mode’ mode.  If the prefix argument is positive, enable the mode,
and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘omni-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Override-Global minor mode (no indicator):
A minor mode so that keymap settings override other modes.

This is a minor mode.  If called interactively, toggle the
‘Override-Global mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘override-global-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Projectile minor mode (no indicator):
Minor mode to assist project management and navigation.

When called interactively, toggle ‘projectile-mode’.  With prefix
ARG, enable ‘projectile-mode’ if ARG is positive, otherwise disable
it.

When called from Lisp, enable ‘projectile-mode’ if ARG is omitted,
nil or positive.  If ARG is ‘toggle’, toggle ‘projectile-mode’.
Otherwise behave as if called interactively.

key             binding
---             -------

s-p     projectile-command-map

s-p ESC     projectile-project-buffers-other-buffer
s-p !       projectile-run-shell-command-in-root
s-p &       projectile-run-async-shell-command-in-root
s-p 4       Prefix Command
s-p 5       Prefix Command
s-p C       projectile-configure-project
s-p D       projectile-dired
s-p E       projectile-edit-dir-locals
s-p F       projectile-find-file-in-known-projects
s-p I       projectile-ibuffer
s-p K       projectile-package-project
s-p L       projectile-install-project
s-p P       projectile-test-project
s-p R       projectile-regenerate-tags
s-p S       projectile-save-project-buffers
s-p T       projectile-find-test-file
s-p V       projectile-browse-dirty-projects
s-p a       projectile-find-other-file
s-p b       projectile-switch-to-buffer
s-p c       projectile-compile-project
s-p d       projectile-find-dir
s-p e       projectile-recentf
s-p f       projectile-find-file
s-p g       projectile-find-file-dwim
s-p i       projectile-invalidate-cache
s-p j       projectile-find-tag
s-p k       projectile-kill-buffers
s-p l       projectile-find-file-in-directory
s-p m       projectile-commander
s-p o       projectile-multi-occur
s-p p       projectile-switch-project
s-p q       projectile-switch-open-project
s-p r       projectile-replace
s-p s       Prefix Command
s-p t       projectile-toggle-between-implementation-and-test
s-p u       projectile-run-project
s-p v       projectile-vc
s-p x       Prefix Command
s-p z       projectile-cache-current-file
s-p <left>  projectile-previous-project-buffer
s-p <right> projectile-next-project-buffer

s-p x e     projectile-run-eshell
s-p x g     projectile-run-gdb
s-p x i     projectile-run-ielm
s-p x s     projectile-run-shell
s-p x t     projectile-run-term
s-p x v     projectile-run-vterm

s-p s g     projectile-grep
s-p s r     projectile-ripgrep
s-p s s     projectile-ag

s-p 5 D     projectile-dired-other-frame
s-p 5 a     projectile-find-other-file-other-frame
s-p 5 b     projectile-switch-to-buffer-other-frame
s-p 5 d     projectile-find-dir-other-frame
s-p 5 f     projectile-find-file-other-frame
s-p 5 g     projectile-find-file-dwim-other-frame
s-p 5 t     projectile-find-implementation-or-test-other-frame

s-p 4 C-o   projectile-display-buffer
s-p 4 D     projectile-dired-other-window
s-p 4 a     projectile-find-other-file-other-window
s-p 4 b     projectile-switch-to-buffer-other-window
s-p 4 d     projectile-find-dir-other-window
s-p 4 f     projectile-find-file-other-window
s-p 4 g     projectile-find-file-dwim-other-window
s-p 4 t     projectile-find-implementation-or-test-other-window


Pyvenv minor mode (no indicator):
Global minor mode for pyvenv.

This is a minor mode.  If called interactively, toggle the
‘Pyvenv mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'pyvenv-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Will show the current virtualenv in the mode line, and respect a
‘pyvenv-workon’ setting in files.

Pyvenv-Tracking minor mode (no indicator):
Global minor mode to track the current virtualenv.

This is a minor mode.  If called interactively, toggle the
‘Pyvenv-Tracking mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'pyvenv-tracking-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

When this mode is active, pyvenv will activate a buffer-specific
virtualenv whenever the user switches to a buffer with a
buffer-local ‘pyvenv-workon’ or ‘pyvenv-activate’ variable.

Rainbow minor mode (indicator Rbow):
Colorize strings that represent colors.
This will fontify with colors the string like "#aabbcc" or "blue".

This is a minor mode.  If called interactively, toggle the
‘Rainbow mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘rainbow-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Rainbow-Delimiters minor mode (no indicator):
Highlight nested parentheses, brackets, and braces according to their depth.

This is a minor mode.  If called interactively, toggle the
‘Rainbow-Delimiters mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘rainbow-delimiters-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Savehist minor mode (no indicator):
Toggle saving of minibuffer history (Savehist mode).

This is a minor mode.  If called interactively, toggle the
‘Savehist mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'savehist-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

When Savehist mode is enabled, minibuffer history is saved
to ‘savehist-file’ periodically and when exiting Emacs.  When
Savehist mode is enabled for the first time in an Emacs session,
it loads the previous minibuffer histories from ‘savehist-file’.
The variable ‘savehist-autosave-interval’ controls the
periodicity of saving minibuffer histories.

If ‘savehist-save-minibuffer-history’ is non-nil (the default),
all recorded minibuffer histories will be saved.  You can arrange
for additional history variables to be saved and restored by
customizing ‘savehist-additional-variables’, which by default is
an empty list.  For example, to save the history of commands
invoked via M-x, add ‘command-history’ to the list in
‘savehist-additional-variables’.

Alternatively, you could customize ‘savehist-save-minibuffer-history’
to nil, and add to ‘savehist-additional-variables’ only those
history variables you want to save.

To ignore some history variables, add their symbols to the list
in ‘savehist-ignored-variables’.

This mode should normally be turned on from your Emacs init file.
Calling it at any other time replaces your current minibuffer
histories, which is probably undesirable.

Shell-Dirtrack minor mode (no indicator):
Toggle directory tracking in this shell buffer (Shell Dirtrack mode).

This is a minor mode.  If called interactively, toggle the
‘Shell-Dirtrack mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘shell-dirtrack-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

The ‘dirtrack’ package provides an alternative implementation of
this feature; see the function ‘dirtrack-mode’.

Show-Paren minor mode (no indicator):
Toggle visualization of matching parens (Show Paren mode).

This is a minor mode.  If called interactively, toggle the ‘Show-Paren
mode’ mode.  If the prefix argument is positive, enable the mode, and
if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'show-paren-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

When enabled, any matching parenthesis is highlighted in ‘show-paren-style’
after ‘show-paren-delay’ seconds of Emacs idle time.

This is a global minor mode.  To toggle the mode in a single buffer,
use ‘show-paren-local-mode’.

Smartparens minor mode (indicator SP):
Toggle smartparens mode.

This is a minor mode.  If called interactively, toggle the
‘Smartparens mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘smartparens-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

You can enable pre-set bindings by customizing
‘sp-base-key-bindings’ variable.  The current content of
‘smartparens-mode-map’ is:

 key             binding
---             -------


Straight-Package-Neutering minor mode (no indicator):
Minor mode to neuter package.el by inhibiting some offensive features.

This is a minor mode.  If called interactively, toggle the
‘Straight-Package-Neutering mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable the
mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'straight-package-neutering-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

This mode is enabled or disabled automatically when straight.el
is loaded, according to the value of
‘straight-enable-package-integration’.

Straight-Use-Package minor mode (no indicator):
Minor mode to enable ‘use-package’ support in straight.el.
The behavior is controlled by variables
‘straight-use-package-version’ and
‘straight-use-package-by-default’. If these variables are
changed, you must toggle the mode function to update the
integration.

This is a minor mode.  If called interactively, toggle the
‘Straight-Use-Package mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'straight-use-package-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

This mode is enabled or disabled automatically when straight.el
is loaded, according to the value of
‘straight-enable-use-package-integration’.

Sublimity minor mode (no indicator):
smooth-scrolling and minimap, like sublime editor

This is a minor mode.  If called interactively, toggle the
‘Sublimity mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'sublimity-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Transient-Mark minor mode (no indicator):
Toggle Transient Mark mode.

This is a minor mode.  If called interactively, toggle the
‘Transient-Mark mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable the
mode if ARG is nil, omitted, or is a positive number.  Disable the
mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'transient-mark-mode)’.

The mode’s hook is called both when the mode is enabled and when it is
disabled.

Transient Mark mode is a global minor mode.  When enabled, the
region is highlighted with the ‘region’ face whenever the mark
is active.  The mark is "deactivated" after certain non-motion
commands, including those that change the text in the buffer, and
during shift or mouse selection by any unshifted cursor motion
command (see Info node ‘Shift Selection’ for more details).

You can also deactivate the mark by typing C-g or
M-ESC ESC.

Many commands change their behavior when Transient Mark mode is
in effect and the mark is active, by acting on the region instead
of their usual default part of the buffer’s text.  Examples of
such commands include M-;, M-x flush-lines, M-x keep-lines,
M-%, C-M-%, s-:, and C-x u.
To see the documentation of commands that are sensitive to the
Transient Mark mode, invoke C-h d and type "transient"
or "mark.*active" at the prompt.

Treemacs-Filewatch minor mode (no indicator):
Minor mode to let treemacs auto-refresh itself on file system changes.
Activating this mode enables treemacs to watch the files it is displaying (and
only those) for changes and automatically refresh its view when it detects a
change that it decides is relevant.

This is a minor mode.  If called interactively, toggle the
‘Treemacs-Filewatch mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'treemacs-filewatch-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

A file change event is relevant for treemacs if a new file has been created or
deleted or a file has been changed and ‘treemacs-git-mode’ is enabled.  Events
caused by files that are ignored as per ‘treemacs-ignored-file-predicates’ are
counted as not relevant.

The refresh is not called immediately after an event was received, treemacs
instead waits ‘treemacs-file-event-delay’ ms to see if any more files have
changed to avoid having to refresh multiple times over a short period of time.

Due to limitations in the underlying kqueue library this mode may not be able to
track file modifications on MacOS, making it miss potentially useful updates
when used in combination with ‘treemacs-git-mode.’

The watch mechanism only applies to directories opened *after* this mode has
been activated.  This means that to enable file watching in an already existing
treemacs buffer it needs to be torn down and rebuilt by calling ‘treemacs’ or
‘treemacs-projectile’.

Turning off this mode is, on the other hand, instantaneous - it will immediately
turn off all existing file watch processes and outstanding refresh actions.

Treemacs-Follow minor mode (no indicator):
Toggle ‘treemacs-follow-mode’.
When enabled treemacs will keep track of and focus the currently selected
buffer’s file.  This only applies if the file is within the treemacs root
directory.
This functionality can also be manually invoked with ‘treemacs-find-file’.

This is a minor mode.  If called interactively, toggle the
‘Treemacs-Follow mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'treemacs-follow-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Treemacs-Fringe-Indicator minor mode (no indicator):
Toggle ‘treemacs-fringe-indicator-mode’.
When enabled, a visual indicator in the fringe will be displayed to highlight
the selected line in addition to ‘hl-line-mode’.  Useful if ‘hl-line-mode’
doesn’t stand out enough with your colour theme.

This is a minor mode.  If called interactively, toggle the
‘Treemacs-Fringe-Indicator mode’ mode.  If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'treemacs-fringe-indicator-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Can be called with one of two arguments:

 - ‘always’ will always show the fringe indicator.
 - ‘only-when-focused’ will only show the fringe indicator when the treemacs
   window is focused (only possible with Emacs 27+).

For backward compatibility just enabling this mode without an explicit argument
has the same effect as using ‘always’.

Treemacs-Git minor mode (no indicator):
Toggle ‘treemacs-git-mode’.

This is a minor mode.  If called interactively, toggle the
‘Treemacs-Git mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'treemacs-git-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

When enabled treemacs will check files’ git status and highlight them
accordingly.  This git integration is available in 3 variants: simple, extended
and deferred.

The simple variant will start a git status process whose output is parsed in
elisp.  This version is simpler and slightly faster, but incomplete - it will
highlight only files, not directories.

The extended variant requires a non-trivial amount of parsing to be done, which
is achieved with python (specifically python3).  It is slightly slower, but
complete - both files and directories will be highlighted according to their git
status.

The deferred variant is the same is extended, except the tasks of rendering
nodes and highlighting them are separated.  The former happens immediately, the
latter after ‘treemacs-deferred-git-apply-delay’ seconds of idle time.  This may
be faster (if not in truth then at least in appearance) as the git process is
given a much greater amount of time to finish.  The downside is that the effect
of nodes changing their colours may be somewhat jarring, though this issue is
largely mitigated due to the use of a caching layer.

All versions run asynchronously and are optimised for not doing more work than
is necessary, so their performance cost should, for the most part, be the
constant time needed to fork a subprocess.

Vertico minor mode (no indicator):
VERTical Interactive COmpletion.

This is a minor mode.  If called interactively, toggle the
‘Vertico mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'vertico-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Which-Key minor mode (no indicator):
Toggle which-key-mode.

This is a minor mode.  If called interactively, toggle the
‘Which-Key mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'which-key-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Windmove minor mode (no indicator):
Global minor mode for default windmove commands.

This is a minor mode.  If called interactively, toggle the
‘Windmove mode’ mode.  If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘(default-value 'windmove-mode)’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Ws-Butler minor mode (indicator wb):
White space cleanup, without obtrusive white space removal.

This is a minor mode.  If called interactively, toggle the
‘Ws-Butler mode’ mode.  If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘ws-butler-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

Whitespaces at EOL and EOF are trimmed upon file save, and only
for lines modified by you.

Yas minor mode (indicator yas):
Toggle YASnippet mode.

This is a minor mode.  If called interactively, toggle the ‘yas
minor mode’ mode.  If the prefix argument is positive, enable the
mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is ‘toggle’.  Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer,
evaluate ‘yas-minor-mode’.

The mode’s hook is called both when the mode is enabled and when
it is disabled.

When YASnippet mode is enabled, ‘yas-expand’, normally bound to
the TAB key, expands snippets of code depending on the major
mode.

With no argument, this command toggles the mode.
positive prefix argument turns on the mode.
Negative prefix argument turns off the mode.

Key bindings:
key             binding
---             -------

C-c     Prefix Command

C-c &       Prefix Command

C-c & C-n   yas-new-snippet
C-c & C-s   yas-insert-snippet
C-c & C-v   yas-visit-snippet-file

[back]
WardBrian commented 2 years ago

If you start emacs without any customization (emacs -Q) and then load stan mode and the file, does it still hang?

rtrangucci commented 2 years ago

I have the same issue, I'm also on emacs 29.0.50 on OSX, 12.1

zhenhua-wang commented 1 year ago

I also have a similar issue on emacs 28.2. Emacs always freezes when typing alphabets in an empty line (I have to C-g every time).

adamgorm commented 1 year ago

I have the same issue as @zhenhua-wang with Emacs 28.2 on Arch Linux. Pressing ENTER to insert a newline while in Stan mode often freezes Emacs and it starts using 100% CPU until I press C-g.

gdario commented 1 year ago

First of all, thank you so much for this package! I have the very same issue on Emacs 28.2 on Mac OS Ventura. I started with a fresh new installation and I have only installed stan-mode to rule out conflicts with other packages. The installation goes smoothly but if I then do C-x C-f myfile.stan and I try to type something in it, nothing happens and Emacs' CPU usage goes up to 100%. I don't know if it can be of any help (probably not), but if I enter toggle-debug-on-quit before visiting the Stan buffer, and then I press C-g I get this traceback.

Debugger entered--Lisp error: (quit)
  looking-at("\\`a\\`")
  c-forward-declarator(nil)
  c-fl-decl-end(2)
  c-change-expand-fl-region(1 2 0)
  #f(compiled-function (fn) #<bytecode -0xa385789fda70470>)(c-change-expand-fl-region)
  mapc(#f(compiled-function (fn) #<bytecode -0xa385789fda70470>) (c-depropertize-new-text c-after-change-escape-NL-in-string c-parse-quotes-after-change c-after-change-mark-abnormal-strings c-extend-font-lock-region-for-macros c-neutralize-syntax-in-CPP c-change-expand-fl-region))
  c-after-change(1 2 0)
  self-insert-command(1 109)
  funcall-interactively(self-insert-command 1 109)
  call-interactively(self-insert-command nil nil)
  command-execute(self-insert-command)
WardBrian commented 1 year ago

I believe something must have changed in the underlying c-mode which is interacting poorly with the customizations we make. I haven't been able to narrow down the issue further or find a solution.

Over the past couple days I've put together the first versions of both a tree-sitter parser for Stan and an emacs major mode to use it (requires Emacs 2.29 + tree-sitter support). This isn't feature complete, especially compared to the eldoc/flycheck/etc features in this repo, but if you just want syntax highlighting it already is just as good if not better than that provided by stan-mode.

https://github.com/WardBrian/tree-sitter-stan https://github.com/WardBrian/stan-ts-mode

This is something I'm going to continue developing in the future, hopefully it eventually is also on MELPA as an option.

gdario commented 1 year ago

Thank you so much @WardBrian. This is great!

kaz-yos commented 1 year ago

Hi @WardBrian , Thank you so much for your information about your next-generation stan packages! Are you interested in taking over the entire stan-mode ecosystem and replacing the major-mode part with your work under development? At this point, I don't work with Stan and have no availability to keep maintaining the aging packages.

adamgorm commented 1 year ago

@WardBrian Thanks a lot!

WardBrian commented 1 year ago

@kaz-yos I'm a bit hesitant to commit to maintaining much more than syntax highlighting. The set of packages in this repo is pretty extensive, and I don't think I understand them all well enough to really maintain them.

If I get stan-ts-mode to a nice place it would probably be good to do what a lot of the built-in modes have done and define a stan-base-mode, then make stan-ts-mode and the existing stan-mode inherit from it. Then things like flycheck-stan can use the stan-base-mode-hook and be enabled in both major modes.

I think I already have write access here, so if I do end up in a position to maintain more I should be able to

eev2 commented 4 months ago

I fixed this by changing in stan-mode.el

;; no type modifiers
(c-lang-defconst c-type-modifier-kwds
  stan nil)

to

;; no type modifiers
(c-lang-defconst c-type-modifier-kwds
  stan '(""))

I hope this works for others too.

gdario commented 4 months ago

Thank you @eev2 for sharing this information! I tried to modify stan-mode.el as you suggest, and I recompiled that file, but it's still hanging. I'm really a noob when it comes to Emacs Lisp. Am I missing an obvious step? Thanks again!

rdiaz02 commented 3 months ago

I have the same issue on Emacs 29.2.50. Here is a minimal reproducible example:

  1. Start emacs with emacs -Q
  2. In the scratch buffer, type and evalute (package-initialize) (to have stan mode available)
  3. Open a file like this
data {
  int<lower=0> N;
  vector[N] Y;
}

parameters {
  real mu;
  real<lower=0> sigma;
}

model {
  mu ~ normal(1.5, 0.1);
  sigma ~ gamma(1, 1);
  Y ~ normal(mu, sigma);
}
  1. Move point to the end of the buffer (M-> or end-of-buffer) and try to insert anything, for example a a. It hangs until you C-g.

  2. This can be repeated at will: do M-x revert-buffer, move to end, try to type anything.

  3. If we use the profiler this is what I see: d1

  4. The modification in https://github.com/stan-dev/stan-mode/issues/69#issuecomment-1927619934 does not completely solve the issue (and, I think, leads to some syntax highlighting issues). But:

    a. If we use the change in https://github.com/stan-dev/stan-mode/issues/69#issuecomment-1927619934 and the file has, say, two or three empty lines at the bottom, and you: a) move to the bottom; b) then move up one line; c) type. This works fine. (Without the code change, this moving around does not prevent the problem).

    b. Likewise, with the above change, if you open the file and insert a newline at the end, and then type anything things work ok. (Without the modification, inserting a newline will not prevent it hanging when you then try to insert a character).

  5. Once it hangs and you C-g, things go back to normal and work fine (you can insert characters anywhere in the file)