Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show org-clock in modeline for all mode? #457

Closed
wztdream opened this issue Jul 5, 2021 · 8 comments
Closed

How to show org-clock in modeline for all mode? #457

wztdream opened this issue Jul 5, 2021 · 8 comments
Labels
invalid This doesn't seem right

Comments

@wztdream
Copy link

wztdream commented Jul 5, 2021

Hi, doom-modeline is great, but seems can not show org-clock, so is it possible to show org-clock in doom-modeline?

@seagle0128
Copy link
Owner

org-clock is displayed in doom-modeline, via org-mode-line-string and global-mode-string.
See the screenshot below.

image

If you don't like this style, you can define your own segment to replace it.

@wztdream
Copy link
Author

wztdream commented Jul 6, 2021

org-clock is displayed in doom-modeline, via org-mode-line-string and global-mode-string.
See the screenshot below.

image

If you don't like this style, you can define your own segment to replace it.

My mistake, the issue is in python mode, the org-clock is gone, so it is better to show org-clock in all modes, how to do that?

@wztdream wztdream changed the title How to show org-clock in modeline? How to show org-clock in modeline for all mode? Jul 6, 2021
@seagle0128
Copy link
Owner

org-clock is displayed everywhere unless it's removed from global-mode-string or mode-line-misc-info.
Simply, eval (doom-modeline-set-main-modeline) in python buffers.

@seagle0128 seagle0128 added the invalid This doesn't seem right label Jul 6, 2021
@wztdream
Copy link
Author

wztdream commented Jul 6, 2021

@seagle0128 Thank you, but eval (doom-modeline-set-main-modeline) not work, there is still no org-clock. And the value of global-mode-string is:

((t
  (:eval lsp-modeline--code-actions-string))
 (t
  (:eval
   (lsp-modeline--diagnostics-update-modeline)))
 (t
  (:eval
   (-keep #'lsp--workspace-status-string
          (lsp-workspaces)))))
Local in buffer test.py; global value is 
("" org-mode-line-string)

value of mode-line-misc-info is:

((which-function-mode
  (which-func-mode
   (#1="" which-func-format " ")))
 (global-mode-string
  (#1# global-mode-string " "))
 (eyebrowse-mode
  (:eval
   (eyebrowse-mode-line-indicator))))

It seems in python mode the global-mode-string is modified as buffer local value, (setq global-mode-string '("" org-mode-line-string)) will recover the org-clock, but it should not be the correct way to solve the issue, it seems related with lsp-mode, but it is strange lsp-mode will modify the mode-line setting, any idea?

by watching global-mode-string the backtrace shows it indeed due to lsp mode, somehow it set a buffer local value, I will issue this case there.

Debugger entered--setting global-mode-string in buffer test.py to ((t (:eval lsp-modeline--code-actions-string)) (t (:eval (lsp-modeline--diagnostics-update-modeline)))): 
  debug--implement-debug-watch(global-mode-string ((t (:eval lsp-modeline--code-actions-string)) (t (:eval (lsp-modeline--diagnostics-update-modeline)))) set #<buffer test.py>)
  add-to-list(global-mode-string (t (:eval lsp-modeline--code-actions-string)))
  lsp-modeline-code-actions-mode()
  run-hooks(lsp-configure-hook)
  lsp-configure-buffer()
  lsp-managed-mode(1)
  lsp--text-document-did-open()
  lsp--open-in-workspace(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 14/14 0x158ea758ac69> :registered-server-capabilities (#s(lsp--registered-capability :id "169bbe02-c1f1-43be-a4b0-62539361faed" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158ea839b0cd>) #s(lsp--registered-capability :id "55d01b1f-f1dc-4bd0-9a60-1aac3ace1bc9" :method "workspace/didChangeWorkspaceFolders" :options #<hash-table equal 0/1 0x158ea7e0e9ed>)) :root "/home/wangzongtao/test" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x158ea90db43d>) :test\? #f(compiled-function () #<bytecode 0x158ea90db449>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 3/65 0x158ea91179d1> :request-handlers #<hash-table equal 0/65 0x158ea822b49d> :response-handlers #<hash-table eql 1/65 0x158ea8570275> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158ea8615d91> :action-handlers #<hash-table equal 0/65 0x158ea861cda9> :major-modes (python-mode) :activation-fn nil :priority 3 :server-id pyright :multi-root t :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x158ea9090749>) :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x158ea861f305> :download-server-fn #f(compiled-function (client callback error-callback update\?) #<bytecode 0x158ea9090755>) :download-in-progress? nil :buffers nil) :host-root nil :proc #<process pyright> :cmd-proc #<process pyright> :buffers (#<buffer test.py>) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158ea7e07cc1> :watches #<hash-table equal 0/65 0x158ea89a2821> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158ea8f3a9d9> :work-done-tokens #<hash-table equal 0/65 0x158ea9d853b9>))
  #f(compiled-function (buffer) #<bytecode 0x158ea75af835>)(#<buffer test.py>)
  mapc(#f(compiled-function (buffer) #<bytecode 0x158ea75af835>) (#<buffer test.py>))
  #f(compiled-function (response) #<bytecode 0x158eaa30d991>)(#<hash-table equal 1/1 0x158ea758ac35>)
  #f(compiled-function (result) #<bytecode 0x158ea8f0a8bd>)(#<hash-table equal 1/1 0x158ea758ac35>)
  #f(compiled-function (result) #<bytecode 0x158ea8f0a8c9>)(#<hash-table equal 1/1 0x158ea758ac35>)
  lsp--parser-on-message(#<hash-table equal 3/3 0x158ea758abdd> #s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 14/14 0x158ea758ac69> :registered-server-capabilities (#s(lsp--registered-capability :id "169bbe02-c1f1-43be-a4b0-62539361faed" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158ea839b0cd>) #s(lsp--registered-capability :id "55d01b1f-f1dc-4bd0-9a60-1aac3ace1bc9" :method "workspace/didChangeWorkspaceFolders" :options #<hash-table equal 0/1 0x158ea7e0e9ed>)) :root "/home/wangzongtao/test" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x158ea90db43d>) :test\? #f(compiled-function () #<bytecode 0x158ea90db449>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 3/65 0x158ea91179d1> :request-handlers #<hash-table equal 0/65 0x158ea822b49d> :response-handlers #<hash-table eql 1/65 0x158ea8570275> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158ea8615d91> :action-handlers #<hash-table equal 0/65 0x158ea861cda9> :major-modes (python-mode) :activation-fn nil :priority 3 :server-id pyright :multi-root t :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x158ea9090749>) :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x158ea861f305> :download-server-fn #f(compiled-function (client callback error-callback update\?) #<bytecode 0x158ea9090755>) :download-in-progress? nil :buffers nil) :host-root nil :proc #<process pyright> :cmd-proc #<process pyright> :buffers (#<buffer test.py>) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158ea7e07cc1> :watches #<hash-table equal 0/65 0x158ea89a2821> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158ea8f3a9d9> :work-done-tokens #<hash-table equal 0/65 0x158ea9d853b9>))
  #f(compiled-function (msg) #<bytecode 0x158ea75af5ad>)(#<hash-table equal 3/3 0x158ea758abdd>)
  mapc(#f(compiled-function (msg) #<bytecode 0x158ea75af5ad>) (#<hash-table equal 3/3 0x158ea6c1b109> #<hash-table equal 3/3 0x158ea758aab9> #<hash-table equal 3/3 0x158ea758abdd>))
  #f(compiled-function (proc input) #<bytecode 0x158ea75ddf11>)(#<process pyright> "Content-Length: 119\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"...")

@wztdream
Copy link
Author

wztdream commented Jul 6, 2021

@seagle0128
I reported this issue to lsp-mode too, but when I use spacemacs mode-line, there is no such issue, so maybe doom-mode-line should update the buffer-local value of global-mode-string too? I am not sure this should be done in doom-mode-line or in lsp-mode?

I double checked spacemacs-mode-line, the value of global-mode-string is the same:

Value:
((t
  (:eval lsp-modeline--code-actions-string))
 (t
  (:eval
   (lsp-modeline--diagnostics-update-modeline)))
 (t
  (:eval
   (-keep #'lsp--workspace-status-string
          (lsp-workspaces)))))
Local in buffer test.py; global value is 
("" org-mode-line-string)

But the org-clock can show in mode line. So it seems spacemacs-mode-line will show both the buffer local and global value of global-mode-string, maybe doom-mode-line should do similar thing too or maybe doom-modeline should do similar update as #2571 ?

@seagle0128
Copy link
Owner

seagle0128 commented Jul 6, 2021

I am using lsp-mode and doom-modeline, and org-clock is displayed correctly as below.
Are you able to reproduce with emacs -Q?

The value of global-mode-string is:

(((t lsp-java-progress-string))
 org-mode-line-string)

If you are using doom-emacs or your personal configuration, you should check your configurations.
It seems lsp-mode modified global-mode-string in your env.

image

@wztdream
Copy link
Author

wztdream commented Jul 6, 2021

I am using lsp-mode and doom-modeline, and org-clock is displayed correctly as below.
Are you able to reproduce with emacs -Q?

The value of global-mode-string is:

(((t lsp-java-progress-string))
 org-mode-line-string)

If you are using doom-emacs or your personal configuration, you should check your configurations.
It seems lsp-mode modified global-mode-string in your env.

image

I use spacemacs, bellow is how you can reproduce it:

  1. close emacs
  2. open emacs
  3. open A.py file ;; here lsp-mode will create buffer local global-mode-string (this step must first)
  4. open B.org file
  5. clock in a task in B.org file ;; clock in only modify global value of global-mode-string, so no org-clock in A.py file mode line
  6. switch back to A.py buffer, there should be no org-clock in modeline

bellow is test results:

  1. emacs -Q ;; no issue
  2. emacs -q -l lsp-start-plain.el ;; no org-clock
  3. use spacemacs only install python layer (which will install lsp layer) remove all personal configuration:
    3.1 use doom-mode-line;; no org-clock
    3.2 use spacemacs mode line;; no issue
    3.3 use vim-modeline;; no issue

@seagle0128
Copy link
Owner

seagle0128 commented Jul 7, 2021

I am not using spacemacs. But, I took a look at the source codes of spaceline. spaceline defines a new org-clock segment to display. I suggest to check if the value of global-mode-string is same as with doom-modeline. The root cause is lsp-mode modified global-mode-string. That's why you was not able to reproduce with emacs -Q.

So, the solution may be

  1. Report and track the issue of lsp-mode.
  2. Define org-clock segment in doom-modeline.
  3. Change the lsp-mode configurations. Refer to here .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants