texts: How to toggle between previous buffer in a given window (e.g toggle-previous-buffer-in-window)?

texts: How can I make Emacs toggle between the previous buffer within a single window (e.g. ignoring buffer changes in other windows)?


texts: Only show an org habit on the agenda a few days into the future

texts:
How can I set up an org habit that repeats 10 days after completion, but only shows up on the agenda if the next instance is less than 6 days away?

An equivalent way of expressing the same thing: a habit that repeats every 10 days, but does not show up until 4 days after the last completion.


texts: Special characters (e. g. umlauts) not displayed correctly in *Org tags* fast tag selection buffer

texts:
In the "Org tags" buffer (the buffer showing the fast tag selection keys when pressing C-c C-c C-c in a headline) some fast selection keys are shown as e. g. [\212] instead of the actual key. How can I fix this?

emacs-version: GNU Emacs 24.4.50.1 (x86_64-apple-darwin13.3.0, NS appkit-1265.21 Version 10.9.4 (Build 13E28)) of 2014-07-05


texts: Elisp expressions in projectile-replace-regexp

texts:
I need to execute a regular expression with case conversion in a entire project. If I run query-replace-regexp in a single file informing '\([A-Z]+\)' and '\,(downcase \1)', it works as expected. But when I try that with projectile-replace-regexp I get the following error:

Invalid use of ‘\’ in replacement text

I investigated it a bit and it seems that the elisp expression doesn't work when query-replace-regexp is not called interactively, because if I run M-: (replace-regexp "'\\([A-Z_]+'\\)" "'\\,(downcase \\1)") I also have the error above.

Am I doing something wrong or is this some limitation? If so, is there another way to achieve this?


texts:
Autocompletion doesn't work with tide or Tern, I have to M-x company-complete-common. I would like for it to keep suggesting with a dropdown menu as I type, but I can't manage to. It works just fine with elpy and go-mode.
I am using emacs 25.3.1 and I have these init lines regarding to js2-mode with tern:

(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; Better imenu
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
(require 'js2-refactor)
(require 'xref-js2)

(add-hook 'js2-mode-hook #'js2-refactor-mode)
(js2r-add-keybindings-with-prefix "C-c C-r")
(define-key js2-mode-map (kbd "C-k") #'js2r-kill)

;; js-mode (which js2 is based on) binds "M-." which conflicts with xref, so
;; unbind it.
(define-key js-mode-map (kbd "M-.") nil)

(add-hook 'js2-mode-hook (lambda ()
 (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))

(require 'company)
(require 'company-tern)

(add-to-list 'company-backends 'company-tern)
(add-hook 'js2-mode-hook (lambda ()
                           (tern-mode)
                           (company-mode)))

;; Disable completion keybindings, as we use xref-js2 instead
(define-key tern-mode-keymap (kbd "M-.") nil)
(define-key tern-mode-keymap (kbd "M-,") nil)

regarding tide:

;; tide
(defun setup-tide-mode ()
 (interactive)
 (tide-setup)
 (flycheck-mode +1)
 (setq flycheck-check-syntax-automatically '(save mode-enabled))
 (eldoc-mode +1)
 (company-mode +1))

;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)

;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)

(add-hook 'typescript-mode-hook #'setup-tide-mode)

There is no error on init, and company-mode is enabled on these modes as expected, it just doesn't start suggesting as typing goes, instead only works for manual completion.


texts: Is there a way to make dired buffers created by lists behave more like traditional dired?

texts:
For example, when doing:

(dired '("custom-buffer" "~/.emacs.d" "/Volumes" "~/.bash_profile"))

I cannot sort, and when changing a name of a file it will not reappear in the buffer. An additional quirk is if I do dired-maybe-insert-subdir on /Volumes dired thinks I'm in the ~/.emacs.d and will not open /Volumes. I know in the docs it says the sorting behavior will not work as expected.

So I suppose I'm just asking if there is a package or something that just makes it so I can list a bunch of files and all the usual dired commands working as expected. Or is there a better way of dealing with an arbitrary group of files? The main feature I would like the most I suppose is sorting.


texts: Tab always indent even in evil normal mode?

texts:
For code editing, and maybe other things too (but not for modes where the tab key has a special behaviour, notably org-mode), I want the tab key to indent, even when in evil normal (or motion) state.

What's the best way to do that?

Currently when I hit tab in evil normal mode in say lisp-mode, there is no effect (that would also be true for python-mode, except I have a special hack for that one case).

I'm using GNU emacs 25 (not spacemacs)


texts: Is it possible to have different color in between a specific patterns?

texts:
I am using \begin{comment} hello world \end{comment} in order to comment out text in AucTex mode.

In general I am using different color for comments but when I use \begin{comment} [text] \end{comment}, the text in between them shows up as white (normal text color). I want it to be seen as in original comment color.

(setq LaTeX-item-indent 0)
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
(require 'tex)

(add-hook 'LaTeX-mode-hook (lambda ()
  (TeX-global-PDF-mode t)
  ))

General question: Is it possible to have different color in between a specific pattern?

Narrowed question: How can I have different color in auxtex for text for all kind of comments such as in between \begin{comment} and \end{comment}


texts:
I'm running emacs on Mac Os, I have settled RVM and a rails project. It works well on console:

 rvm list
rvm rubies

=> ruby-2.1.6 [ x86_64 ]
 * ruby-2.4.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

and also running the rails console

RAILS_ENV=development bundle exec rails console
Loading development environment (Rails 3.2.22.4)
2.1.6 :001 >

But when, I run emcas as OSX APP, rvm works well rvm-activate, and then running the console I get this:

Ignoring bcrypt-3.1.11 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.11
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
Ignoring byebug-9.0.6 because its extensions are not built.  Try: gem pristine byebug --version 9.0.6
Ignoring debug_inspector-0.0.2 because its extensions are not built.  Try: gem pristine debug_inspector --version 0.0.2
Ignoring eventmachine-1.0.8 because its extensions are not built.  Try: gem pristine eventmachine --version 1.0.8
Ignoring executable-hooks-1.3.2 because its extensions are not built.  Try: gem pristine executable-hooks --version 1.3.2
Ignoring ffi-1.9.8 because its extensions are not built.  Try: gem pristine ffi --version 1.9.8
Ignoring gem-wrappers-1.3.2 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.3.2
Ignoring gpgme-2.0.11 because its extensions are not built.  Try: gem pristine gpgme --version 2.0.11
Ignoring hitimes-1.2.6 because its extensions are not built.  Try: gem pristine hitimes --version 1.2.6
Ignoring json-1.8.6 because its extensions are not built.  Try: gem pristine json --version 1.8.6
Ignoring json-1.8.3 because its extensions are not built.  Try: gem pristine json --version 1.8.3
Ignoring libv8-3.16.14.7 because its extensions are not built.  Try: gem pristine libv8 --version 3.16.14.7
Ignoring mysql2-0.3.18 because its extensions are not built.  Try: gem pristine mysql2 --version 0.3.18
Ignoring nokogiri-1.6.8 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.8
Ignoring passenger-5.0.26 because its extensions are not built.  Try: gem pristine passenger --version 5.0.26
Ignoring rainbow-2.2.2 because its extensions are not built.  Try: gem pristine rainbow --version 2.2.2
Ignoring ruby-prof-0.13.0 because its extensions are not built.  Try: gem pristine ruby-prof --version 0.13.0
Ignoring sqlite3-1.3.11 because its extensions are not built.  Try: gem pristine sqlite3 --version 1.3.11
Ignoring therubyracer-0.12.1 because its extensions are not built.  Try: gem pristine therubyracer --version 0.12.1
Ignoring thin-1.6.4 because its extensions are not built.  Try: gem pristine thin --version 1.6.4
Ignoring websocket-driver-0.3.0 because its extensions are not built.  Try: gem pristine websocket-driver --version 0.3.0
Could not find bcrypt-3.1.11 in any of the sources
Run `bundle install` to install missing gems.

Process rails exited abnormally with code 7

This doen't happen, when running emacs form console, so I do not know how to set this


texts:
How does org-mode implement syntax highlighting for code blocks? More specifically, for a C file, does it use cc-mode or does it have its own algorithm? For example, if I have this org file: test.org:

* Example source code in C:

#+BEGIN_SRC c
#include <stdio.h>

int main() {
    printf( "Hello world\n" );
    return 0;
}
#+END_SRC

I get the following highlighting:

But if have the same pure C file (using cc-mode) test.c:

#include <stdio.h>

int main() {
    printf( "Hello world\n" );
    return 0;
}

I get:

Notice that printf has different face color in the two files. So it seems like org-mode has its own syntax highlighting. It is not using cc-mode to do the highlighting, is that correct?


texts: OrgMode table text narrowing issue with links

texts:
I have an issue with my GNU Emacs 26.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.8) of 2019-04-30 in OrgMode.

I have a table. One of its collumn is filled with internal links (inside document further). And when I try to narrow text (I need to export document it to ODT) in table it says: Cannot narrow field starting with wide link ... .

So, what do I do?

UPD. Sample.

* Pivot table

  | ##    | Task                                                                                | Time |
  |-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+------|
  | <l5>  | <l15>                                                                                | <r10> |
  | 1     | [[*Task #1: This task has small description][Task #1: This task has small description]]                                                                                |      |
  | 2     | [[*Task #2: But this task has large, very large, very very large description with many, many subtasks not described yet but must be described next saturday][Task #2: But this task has large, very large, very very large description with many, many subtasks not described yet but must be described next saturday]] |      |

* Tasks

** Task #1: This task has small description

   Simple task 1

** Task #2: But this task has large, very large, very very large description with many, many subtasks not described yet but must be described next saturday

   Simple task 2


texts: the following functions might not be defined at runtime: lsp-format-buffer, lsp-organize-imports function ‘dap-go-setup’ is not known to be defined

texts:
I 've below emacs init file config setup
I'm getting below error in the emacs startup. I don't know what might be the root cause of the issue

the following functions might not be defined at runtime: lsp-format-buffer, lsp-organize-imports
the function ‘dap-go-setup’ is not known to be defined.

The emacs file is  -
~/.emacs.d/init.el file is
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

(package-initialize)

(add-to-list 'package-archives
            '("melpa-stable" . "https://stable.melpa.org/packages/") t)

(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))

(require 'use-package)

(load "~/.emacs.d/golang.el")

My ~/.emacs.d/golang.el file is -
(use-package lsp-mode
:ensure t
:commands (lsp lsp-deferred)
:hook (go-mode . lsp-deferred))

;; Set up before-save hooks to format buffer and add/delete imports.
;; Make sure you don't have other gofmt/goimports hooks enabled.
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)

;; Optional - provides fancier overlays.
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode
:init)

;; Company mode is a standard completion package that works well with lsp-mode.
(use-package company
:ensure t
:config
;; Optionally enable completion-as-you-type behavior.
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 1))

(use-package company-lsp
:ensure t
:commands company-lsp)

;; Optional - provides snippet support.
(use-package yasnippet
:ensure t
:commands yas-minor-mode
:hook (go-mode . yas-minor-mode))

(use-package dap-mode
;;:custom
;;(dap-go-debug-program `("node" "~/extension/out/src/debugAdapter/goDebug.js"))
:config
(dap-mode 1)
(setq dap-print-io t)
;;(setq fit-window-to-buffer-horizontally t)
;;(setq window-resize-pixelwise t)
(require 'dap-hydra)
(require 'dap-go)       ; download and expand vscode-go-extenstion to the =~/.extensions/go=
(dap-go-setup)
(use-package dap-ui
    :ensure nil
    :config
    (dap-ui-mode 1)
    )
)

(use-package flycheck-golangci-lint
:ensure t)

(setq lsp-ui-doc-enable nil
    lsp-ui-peek-enable t
    lsp-ui-sideline-enable t
    lsp-ui-imenu-enable t
    lsp-ui-flycheck-enable t)

(setq lsp-gopls-staticcheck t)
(setq lsp-eldoc-render-all t)
(setq lsp-gopls-complete-unimported t)

My operating system is -
$ lsb_release -a
LSB Version:    n/a
Distributor ID: ManjaroLinux
Description:    Manjaro Linux
Release:    20.2
Codename:   Nibia

What is the root cause of this issue?


texts: Detect/specify the monitor a frame is on?

texts:
Q: how do I detect/specify the monitor a frame is on?

I'm working off of a laptop that has an external monitor connected
to it.  I therefore have two monitors (call them INTERNAL and
EXTERNAL).

On occasion, I want to do the following:

Adjust an existing frame's parameters based on the monitor
 it's on
Make a new frame on the other monitor

I think I can tell which monitor I'm currently on with
frame-monitor-attributes.

However, I don't know how to address point 2: given that I'm on
monitor EXTERNAL, how do I make a new frame on monitor INTERNAL
(and vice versa)?

I suspect I could rig something up by accessing the x location, but that seems hacky to me.

Notes:

I've looked at make-frame-on-display, but, unless I'm misunderstanding, "display" here means an X display or a terminal.
Related threads that don't quite resolve point 2:

Is there a way to detect change of monitor in Emacs / Elisp?
Determine whether a frame is shown on primary display


texts: How to archive all completed tasks under a headline?

texts:
I've got an org file that looks like this:

* Project Cats
** Get them
*** TODO Find a tabby
*** DONE Find one that's orange
    CLOSED: [2016-11-08 Tue 15:32]
** Feed them
*** DONE Buy some food
    CLOSED: [2016-11-08 Tue 15:32]
*** TODO Put it in bowls

Is there a command that, with my cursor on the top headline, will archive everything marked as DONE that's a descendant? After running such a command, I'd expect to see this:

* Project Cats
** Get them
*** TODO Find a tabby
** Feed them
*** TODO Put it in bowls


texts:
When I want to insert an environment in latex, I usually call LaTeX-environment by hitting C-C C-e. However, some environment requires extra parameters, like 'aligned' requires a position or 'proof' requires a title. In almost all cases I just hit enter to accept a default setting (no position or no title).

Is there a way to change this behavior so that for these environment the default option is always adopted with no extra interaction?


texts: How do I prevent emacsclient --tty FILE from flashing the other frame's buffer before loading FILE

texts:
With emacs -Q if you M-x server-start, then open a buffer, then back in the terminal emacsclient --tty SOMEOTHERFILE a new frame will be created, but it will initially show the buffer shown in the original frame prior to displaying the file/buffer specified on the command line.

I know this is a visual nit, but it's distracting. Is there a way to prevent this from happening? Either by showing the scratch buffer initially or loading straight in to the file specified at the command line?


texts: Implement Scheduling as suggested in “Deep Work” using Emacs org-mode

texts:
In his book "Deep Work", Cal Newport suggests to schedule every minute of your day doing the following:

  Divide the hours of your workday into blocks and assign activities to the blocks. [..] Not every block need to be dedicated to a work task. (Deep Work, p. 223)

Since I am using Emacs' org-mode to schedule my work tasks and planning my work day, I would like to implement the above strategy using these tools. As far as I know org-mode only supports scheduling tasks but the idea of Newport's strategy above is that these blocks should not be individual tasks.

Of course, I could create "placeholder tasks" for the blocks but this not seem to be a natural approach. Therefore I am looking for advice or suggestions to implement the above using Emacs.

This is a cross-post with this question on personal productiviy where the question did not get much attention.


texts: How to match first character in line after asteriks and space using regex?

texts:
For example i have lines:

* test1
** another tests
* some other line

I would like to match t in first line, a in second, s in third.


texts:
I am not able to bind Meta + Shift + any character.
I do not experience these problems with other key combinations (such as Control + Shift + Key).
Below is the specific case that I cannot get to work:
(global-set-key (kbd "M-S-Z") 'zap-up-to-char-backward)
(defun zap-up-to-char-backward (char)
  (interactive "cZap up to char (backward): ")
  (zap-up-to-char -1 char))


texts: Conflict between emmet-mode and yasnippet, same trigger key

texts:
I want to have both emmet-mode and yasnippet trigger with the same key C-return: in a html-mode buffer, C-return should first try yas-expand and then emmet-expand-line if no suitable snippet was found.

It seems I am missing something about the binding keywords in use-package. Currently only emmet-mode's bind is active in a HTML buffer.

lisp/init-emmet.el

(use-package emmet-mode
  :defer t
  :init
  (add-hook 'css-mode-hook 'emmet-mode)
  (add-hook 'sgml-mode-hook 'emmet-mode)
  :config
  (setq-default
   emmet-move-cursor-between-quotes t
   emmet-preview-default nil)
  (unbind-key "C-M-<left>" emmet-mode-keymap)
  (unbind-key "C-M-<right>" emmet-mode-keymap))

lisp/init-yasnippet.el

(use-package yasnippet
  :defer t
  :bind (:map yas-minor-mode-map ("<C-return>" . yas-expand))
  :init
  (add-hook 'js-mode-hook 'yas-minor-mode)
  (add-hook 'sgml-mode-hook 'yas-minor-mode)
  :config
  (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
  (yas-reload-all)
  (unbind-key "TAB" yas-minor-mode-map))


texts: My change to the default font size reverts at startup

texts:
When I start Emacs with emacs -Q --eval '(set-face-attribute (quote default) nil :height 180), the font changes for a split-second, but then returns to its default. Same thing if I put the code in my init file.

If I deliberately cause an error with emacs -Q --eval '(progn (set-face-attribute (quote default) nil :height 180) (bing)), the change sticks. But this doesn't work if I put the code in my init file—I guess that whatever mechanism Emacs uses to recover from init-file errors doesn't prevent the font-size-revert code from running.

How do I get Emacs to accept my default font size?

I'm running Emacs 25.1.2 (from kelleyk's PPA) on Ubuntu 16.10.


texts: Say I create a quick keyboard macro, but find that executing it in quick succession is extremely slow. How can I determine in what functions or packages this command is spending most of its time? Maybe some convenient help binding like C-h % which will then display the performance details for the next command executed.


texts:
When I run sql-mysql, it gives me an unusable console:

Note how the commands and results are misplaced. My emacs version is 24.5.1.


texts: Why doesn't "complement" work as a function?

texts:
I'm trying to implement the complement function from Common Lisp (CL) in Emacs Lisp, but I'm confused by why defining it as a function (as opposed to a macro) does not work.

The macro definition is straightforward:

(defmacro complement (function)
  `(lambda (&rest args)
     (not (apply ,function args))))

The function definition, however, does not work.

(defun complement (f)
  (lambda (&rest args)
    (not (apply f args))))

Something like (complement #'zerop) gives

(lambda (&rest args) (not (apply f args)))

Where the f is not replaced with the zerop.

Why is this? The equivalent function definition works fine in CL. Does it have something to do with scope?


texts: How to specify a LINK in org-anniversary to jump from org-agenda

texts:
The idea is to add a LINK after
%%(org-anniversary 2006 3 21) World Down Syndrome Day (%d years) <LINK>

So when I see it in my agenda for that day, I can click and jump to a ORG heading in a ORG buffer where I can learn more about the event. I tried using C-c l (org-store-link), but it fails. Any help, thanks!


texts:
I'm having the following problem: In emacs the tool bar icons are invisible as can be seen here. There should be icons like visit new file, save buffer etc below the menu at the top and above the buffer. By the way, they aren't missing, I can still click them. The icons are just blank. I can even hover over them or press them, it all works.

I have no idea why this happened, nor do I know how to fix it. Any suggestions?


texts:
Upon striking C-x s (save-some-buffers) or C-x C-c,
it report errorsin mini-buffer

Making resize-mini-windows buffer-local while locally let-bound.

Search the above errors but return no helpful results.

How could solve the problem?


texts: Is there Sublime Text - style command palette in Emacs?

texts:
There is such feature as Command Palette in Sublime text:

It provides searchable list of command with human-readable descriptions.

Is there anything similar to this in Emacs?


texts: projectile suggests a file that does not exist

texts:
I am just starting to test projectile.

My understanding is that projectile-find-file looks into my whole repository for the file I'm looking for.

I am also currently working on the file structure of my project. When trying to open a file (one I have moved), both the new and the old location show up as suggestion. If I choose the old location, a new file is created.

My questions:

is the file location information cached somewhere, in that case where? I installed projectile after moving the file. How can I clean the old info?
is there a way to prevent projectile from creating files? I'm happy with returning to ido-find-file for file creation.

More details: I am upgrading an SDK that is a submodule of my repo, and the new version has another file structure.

# the old file (note the "old" in the path):
vendor/nrf5-sdk-old/components/drivers_nrf/spi_master/nrf_drv_spi.h
# the new file:
vendor/nrf5-sdk/integration/nrfx/legacy/nrf_drv_spi.h

When I run projectile-find-file in my project:

Note the second suggestion, which is a file that does not exist. What exists is this file, but in nrf-sdk-old instead of nrf-sdk as advertized.

I've tried moving away the nrf-sdk-old altogether, the suggestion keeps coming up.

EDIT: I've tried removing my TAGS file. The old path is still in my checked out commit, though (but not in working files). Could that be it?


texts: GnuTLS / OpenSSL hangs on Windows when accessing Gmail

texts:
I am trying to set up Gnus (on Emacs 24.5) on Windows to access Gmail through IMAP and it seems like the connection is choking when it attempt to connect to the IMAP server. (Seems like Gnus is not attempting to send authentication data, either.)

It basically hangs while showing "Opening TLS connection to `imap.googlemail.com'...done" and I will have to Ctrl-G to stop it. (I left it for an hour and still didn't work, either.) For both situations where I tried to use gnutls-cli or openssl, it seems to be hanging in exactly the same places, where it seems to be the server is waiting for the client to talk to it, but Gnus never talks to it.

* OK Gimap ready for requests from  e203mb4768837ita

I thought it was something to do with .authfile being encrypted, but it seems like Gnus is not even trying to touch it, and didn't work when I tried it with the plain text outfield.

(setq tls-program '("c:/Progra~2/Git/bin/openssl.exe s_client -connect %h:%p -no_ssl2 -ign_eof -CAfile c:/full/path/to/ca-bundle.crt"))

The odd thing is same configuration works on Linux and Mac on the same network, just Windows machine that's having issues.

(setq gnus-secondary-select-methods
  '((nnimap "server"
            (nnimap-address "imap.googlemail.com")
            (nnimap-server-port 993)
            (nnimap-stream ssl)
            (nnimap-authinfo-file "~/.authinfo"))))

If there something I can try to fix this, and/or suggestions/insights will be highly appreciated!

Thank you.


texts:
Basically, I am looking for an autocomplete-mode that suggests words as ido-mode does on file. Meaning,
if I've typed "em" and the autocomplete suggests two words "Emacs" and "Emacsclient" , it should suggest "Emacsclient" if I type any of "l", "i", "e", "n" or "t" next.

Is such thing already there. Native auto-complete mode doesn't do that. So, is there any other package that any of you are aware of that does such thing?


texts: Keep ivy-initial-inputs-alist nil after counsel loaded

texts:
I want to keep the alist ivy-initial-inputs-alist nil after ivy and counsel are loaded. Therefore, I have the following configuration:

(use-package ivy
  :ensure t
  :config

  ;; some keybindings

  (setq ivy-initial-inputs-alist nil))

However, this doesn't work after counsel is loaded. When I check the alist value, I get this:

Value:
((counsel-minor . "^+")
 (counsel-package . "^+")
 (counsel-org-capture . "^")
 (counsel-M-x . "^")
 (counsel-describe-function . "^")
 (counsel-describe-variable . "^"))
Original value was
((org-refile . "^")
 (org-agenda-refile . "^")
 (org-capture-refile . "^")
 (Man-completion-table . "^")
 (woman . "^"))

meaning that the alist was set to nil, but counsel set it again later.

The only line that has something to do with ivy-initial-inputs-alist in counsel.el is:

(cl-pushnew '(counsel-package . "^+") ivy-initial-inputs-alist :key #'car)

How can I make the setq persistent?


texts: Show the *Completions* buffer automatically when starting completing-read

texts:
I want to do a completing read with the *Completions* buffer already shown (because I'm providing initial input that I already know is an ambiguous prefix). How can I do it?

I don't see an option for this in completing-read. I want a method that works in both Emacs 23 (where completing-read is defined in C) and in Emacs 24 (where completing-read relays to the function indicated by the variable completing-read-function, so I suppose I could just change that) — of course a solution based on (if (boundp 'completing-read-function)) is fine.

Although my immediate use case is with a known ambiguous initial input, something that works regardless of that would be nice. Also, if the user has overridden the default read mechanism (e.g. by redefining completing-read to invoke ido-completing-read or anything-completing-read or by turning on Icicles or Helm), I'd like my code to achieve the same effect, i.e. start the completion mechanism with the list of completions already shown.


texts: When I run shell-command in a new session I do not have access to the history of commands from the last session. How can I have that?


texts: Recentering if multiple-cursors goes out the screen?

texts: How can I make the functions of multiple-cursors recenter if the next or previous candidate if not show in current screen automatically? Although I known I can do it by C-v and M-v manually. Thanks in advance !


texts: How to iterate over JSON list and select one element

texts:
Say I have a list of names with ids, in JSON:

(let ((json-object-type 'plist))
  (setq mylist (json-read-from-string "[{\"name\": \"Adam\", \"id\": \"1\"},
                                        {\"name\": \"Eve\", \"id\": \"2\"}]")))

I want to find out Adam's id.  How do I do that?

I'm currently trying

(dolist (person  mylist)
  (when (equal "Adam" (plist-get person :name))
    (setq person_id (plist-get person :id)))
  )

But this raises setq: Wrong type argument: listp, [(:id "1" :name "Adam") (:id "2" :name "Eve")]


texts: Switch to most recent buffer in a given mode

texts:
I am trying to create a function that switches to the most recent buffer in major mode major-mode. An answer to a related question supplies a function that should require the smallest of tweaks to serve my purpose, but I can't make it work. Here is the original function in that answer:
(defun switch-to-most-recent-org-buffer ()
  (interactive)
  (let (found)
    (catch 'done
      (mapc (lambda (x)
              (when (with-current-buffer x (eq major-mode 'org-mode))
                (switch-to-buffer x)
                (setq found t)
                (throw 'done nil)))
            (buffer-list))
      (unless found (message "not found")))))

I thought I could just replace the first and sixth lines, respectively, with
(defun switch-to-most-recent-buffer-in-mode (major-mode)

and
              (when (with-current-buffer x (eq major-mode major-mode))

Which gives me this:
(defun switch-to-most-recent-buffer-in-mode (major-mode)
  (interactive)
  (let (found)
    (catch 'done
      (mapc (lambda (x)
              (when (with-current-buffer x (eq major-mode major-mode))
                (switch-to-buffer x)
                (setq found t)
                (throw 'done nil)))
            (buffer-list))
      (unless found (message "not found")))))

but it doesn't work: while the original function switches to my most recent org buffer, evaluating (switch-to-most-recent-buffer-in-mode org-mode) returns a "not found" message. It seems I am failing to grasp something very basic about Elisp, so please excuse my ignorance: I'm not a programmer and am new to Emacs.
--
[edited to add:] The amended code below works (taken from phils's answer).
(defun switch-to-most-recent-buffer-in-mode (mode)
  (interactive "C")
  (let (found)
    (catch 'done
      (mapc (lambda (x)
              (when (with-current-buffer x (eq major-mode mode))
                (switch-to-buffer x)
                (setq found t)
                (throw 'done nil)))
            (buffer-list))
      (unless found (message "not found")))))


texts:
I am able to add few extra sources to helm like this

(setq helm-mini-default-sources '(helm-source-buffers-list
                                  helm-source-recentf
                                  helm-source-dired-recent-dirs
                                  helm-chrome-source
                                  hgs/helm-c-source-stars
                                  hgs/helm-c-source-repos
                                  hgs/helm-c-source-search
                                  helm-source-buffer-not-found))

The last thing i need to add to this is helm-M-x. I just need to add all commands to default sources. By this i can invoke a single function and I can go to anything or i can invoke any command.

But helm-M-x is a function and its source-code doesn't have any sources. Any help on how to achieve this?


texts: How to exclude TODO state change messages from export?

texts:
Org-Mode can automatically track TODO state changes as described in the docs. It also allows the option todo: nil option, as mentioned here, so that TODO keywords will not appear in an export.

It seems rather intuitive to me that if I set todo: nil then I don't want messages like • State “NEXT” from "" [2015-04-23 Thu 18:44] to appear when I export. But they do appear, at least for me they do, in Org-Mode version 8.2.10.

If there is another option to do what I want, I'm not seeing it. Does anyone have a good fix for this?


texts: Get the syntax coloring of another mode for newly defined mode

texts: I am defining a new mode in emacs, but I want to have the same syntax highlighting as Org mode. How can I do this?


texts: Better syntax-higlighting for member variables and function calls in cpp-mode

texts:
In atom, C++ files are well colored unlike emacs cpp-mode. Emacs does not highlight references to member variables, function calls or member functions. They all are uncolored.

The left is from emacs and the other is from atom:

See, emacs does not syntax-color for variables and functions apart from their declarations.

Emacs does not utilize a semantic syntax highlighting system, neither does atom. I think such highlighting can be easily added using regexp like in atom.

Atom, for example, looks for parantheses to distinguish function calls from variables. Similarly it looks for a dot to distinguish member variables from the others.

I would like to add these coloring rules to emacs, however, I am just a beginner who does not know regexp and font-lock-mode.

Could you help me with this issue?


texts: How to create Spacemacs keybinding starting with "SPC"?

texts:
I'm trying to add a keybinding by doing the following:

(global-set-key (kbd "SPC-;") 'spacemacs/default-pop-shell)

but it gets interpreted as the separate keys S, P, etc and produces the error:

global-set-key: Key sequence S P C - ; starts with non-prefix key S

What is the correct way to map something starting with SPC?

I'm not sure if any of this is specific to Spacemacs, but that's the distro I'm using.


texts:
Recently, I have tried setting up a JS development environment and part of that process has been configuring company-mode for autocompletion duties - but I'm having some issues triggering auto completion. First - here's the file I use to configure company mode:

(use-package yasnippet
  :ensure t
  :diminish yas-minor-mode
  :config
  (setq yas-snippet-dirs (append yas-snippet-dirs
                                 '("~/.emacs.d/snippets/")))
  (yas-global-mode 1))

(use-package company
  :ensure t
  :diminish company-mode
  :config
  (add-to-list 'company-backends 'company-elisp)
  (add-to-list 'company-backends 'company-yasnippet)
  (add-to-list 'company-backends 'company-dabbrev)
  (add-to-list 'company-backends 'company-dabbrev-code)
  (add-to-list 'company-backends 'company-etags)
  (setq company-auto-complete nil
        company-tooltip-flip-when-above t
        company-minimum-prefix-length 2
        company-tooltip-limit 10
        company-idle-delay 0.5)
  (global-company-mode 1))
;;  (add-hook 'prog-mode-hook 'company-mode))

(use-package helm-company
  :ensure t
  :config
  (progn
    (define-key company-mode-map (kbd "C-:") 'helm-company)
    (define-key company-active-map (kbd "C-:") 'helm-company)))

(use-package company-tern
  :ensure t
  :init
  (add-to-list 'company-backends 'company-tern))

(use-package tern
  :ensure t
  :defer t
  :diminish tern-mode
  :config
  (progn
    (add-hook 'js2-mode-hook 'tern-mode)))

(provide 'init-autocompletion)

Now, let's say I'm working in a...Coffeescript file - and it has something like this:

foo =
  addTwo: (a) ->
    a + 2
  addThree: (a) ->
    a + 3

then later on in that file I start typing:

foo.a...

I would hope that company would kick in and offer addTwo/Three as candidates - but I got nada!

I ran company-diag - and I get this:

Emacs 24.5.1 (x86_64-apple-darwin14.4.0) of 2015-07-13 on MFT-A018.local
Company 0.9.0-cvs

company-backends: (company-tern company-etags company-dabbrev-code company-yasnippet company-elisp company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-files company-dabbrev)

Used backend: company-etag

and a whole bunch of completion candidates - none of which are foo.addTwo/Three

can anyone offer any advice on how to get company-mode working?


texts: Enable Evil jump to work across all panes instead of only active pane

texts:
Is there a way to enable evil-jump-forward and evil-jump-backward to use the jump list of all panes instead of only the active pane?

In the gif below, here's what happens:

Start on left pane at bottom.
Go to beginning of the buffer on the left.
Move to the pane on the right at the bottom of the buffer.
Go to beginning of buffer on the right pane.
Press C-o for evil-jump-backwards four times.  The focus always stays in the pane on the right.

Is there a way to make the focus take into account panes as well?


texts:
I have a file, with a lot of instances of

...
fclose(f1);
fclose(f2);
fclose(f3);
...

I'd like to replace these with

...
if(fclose(f1)!=0) return 1;
if(fclose(f2)!=0) return 1;
if(fclose(f3)!=0) return 1;
...

But, other than doing two separate search-and-replace, i haven't found a way to do this, which preserves the argument.
I think the regex version of search-and-replace may be able to do this, but I'm not nearly proficient at regexes to know how.


texts: Getting permissions errors related to /var/folders directory after doing mac migration

texts:
I am running spacemacs emacs and recently had to migrate my macbook to a new macbook. After doing that, I am having trouble using magit. When I try to commmit using magit from the magit status interface, I get an error:

  files--ensure-directory: Creating directory: Permission denied, /var/folders/8sUnable to load color "#212026"

I also see what seems to be a related error on startup:

  Error running timer ‘mac-setup-help-topics’: (file-missing "Creating file with prefix" "No such file or directory" "/var/folders/8s/y0zrtc6n38j0gwnvz7_l4q1h0000gn/T/jka-com")

I've got no idea how to go about debugging for fixing this. Does anyone have any ideas?

What I've tried so far:
1) Remove the .emacs.d folder and reinstall spacemacs.
2) Reinstall the emacs for mac release from here


texts:
Is there a way to remove unsaved text and get back the latest saved state of a file in Emacs without using undo?

Like this:

| a - write some text to save
| b - save the file
| c - add some text to remove
| d - more text  to remove
| e - command/function to remove all text after b


texts: File within a root grandparent is detected by emacs as belonging to a directory that doesn't exists

texts:
I'm editing a file within a directory /parentdir/userdir/file with the following permissions:
$ sudo namei -l $(pwd)
drwxr-xr-x   root   root   /
drwx------   root   root   parentdir
drwx--S---   myuser myuser userdir
-rw-------   myuser myuser file

Additionally, both parentdir and userdir have set a facl rule that, by default, creates files and directories without any permission for group or others. In any case, my PWD is /parentdir/userdir and I have full permissions to edit file.
However, if I edit file using emacs, when trying to save the changes, it says to me that the directory /parentdir/userdir/ doesn't exists, and asks me if I want to create it.
How can I skip that message in a safe way? Maybe the reason is that emacs is trying to save the file using absolute paths, and it gets confuses since it has no execute permissions to access that directory.


texts: Getting flycheck "jump to next/previous error" to cycle

texts:
I'd like M-g n and M-g p to cycle, at least when I'm using them with flycheck. This feature requires writing a custom function as it's not supported (as mentioned on https://github.com/flycheck/flycheck/issues/64 and confirmed in chat), but I am an Elisp noob.

For other reasons (working around https://github.com/commercialhaskell/intero/issues/268), in flycheck-mode I bypass next-error and invoke flycheck-next-error directly. I can live with normal compilation mode not cycling since I use it seldom (though probably this will get annoying if I do start using compilation mode).


texts: How can I pass an argument (via highlighting) to a shell command while also passing the filename as an argument?

texts:
Im attempting to run a perl script on a buffer which will rearrange/edit the contents. I want to highlight a string and let that be my input as well as the buffer or file.

Currently I can come close. I know C-x h M-| shell command will pass the buffer to STDIN which can be used. But it doesnt give me the ability to also pass a string.

Is there a way to pass both?


texts: How can I see multiple specific todo-states in a custom agenda view without abusing org-agenda-skip-function?

texts:
I am trying to build a 'cleanup' agenda view, with a section for all tasks which are done and a review section for tasks in the HOLD or WAITING states. HOLD and WAITING are states I've defined as incomplete in

(setq org-todo-keywords '(
                      (sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
                      (sequence "HABIT(x)" "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING")))

I've tried to add a custom agenda command

("c" "Cleanup" ((todo '("WAITING" "HOLD")

etc, which I based off of the skip format, such as

(org-agenda-skip-function '(org-agenda-skip-entry-if 'todo '("NEXT" "HABIT")))

which works fine. As a view definition though, this doesn't work. What is a good way to get a view of only the specific TODO states I want without manually skipping every other state?


texts:
Is there an emacs mode for editing and typsetting wiki wiki modes?

What I am looking for is something that could help me writing a properly formatted document for wikipedia.


texts:
I use display-buffer-alist to Configure buffer display. For example I have this snippet to display flycheck errors buffer.

(add-to-list 'display-buffer-alist
             `(,(rx bos "*Flycheck errors*" eos)
               (display-buffer-reuse-window
                display-buffer-below-selected)
               (reusable-frames . visible)
               (side            . bottom)
               (window-height   . 0.4)))

This works well, but when I want the same behaviour for the Messages buffer, it doesn't work. Why does this only work for certain buffers ?

And is it also possible to configure the display for buffers, that are opened by specific commands ? One example is shell-mode. When I open a new shell buffer, with another one already existing, my display modifications don't work because the name of the buffer is different.


texts: Minimap package line highlight always on

texts:
I've installed a minimap package and when I disable and save 'show minimap line highlight' it keeps showing the line highlight anyway:

Any obvious fixes, or is it just a bug in the package?


texts: org-export subtree to filename.pdf with EXPORT_FILE_NAME fails

texts:
I'm trying to export subtrees using #+PROPERTY: EXPORT_FILE_NAME filename as described in the Org manual at bottom here.

I have a test file called test.org:

* This Is A Test
  #+PROPERTY: EXPORT_FILE_NAME export-test
  here is some content
* This Is Another Test
  #+PROPERTY: EXPORT_FILE_NAME another-export-test
  here is some more content.

When I put point on either * heading and export with C-c C-e C-s l o the resulting PDF file has the correct content, but is not called "export-test" or "another-export-test" but instead "test.pdf". I'm a beginner at this, and can't fathom what I'm doing wrong.

Org 8.3.1

Emacs 24.5.1


texts: Mapping a function over `frame-list` to get a list of the `top` frame-parameter values

texts:
I'd like to make a list of parameters of each frame such as the top coordinate, left coordinate, and name to achieve what I asked in my previous question. I'm trying to follow the advice I got there and wrote a snippet to print the top coordinates of each frame, but it doesn't work. Could anyone tell me which part is wrong?

(message "%s" (mapcar (cdr (assq 'top (frame-parameters)))) (frame-list))

It returns

Invalid function:(mapcar (cdr (assq 'top (frame-parameters))))


texts:
Are there idiomatic boolean comparators in emacs lisp?

Something like:

(my/bool< nil t)
 => t
(my/bool< 1 2)
 => nil

For example, a comparator that returns t if the first argument is nil and the second is truthy (per common association of '0' with 'false' or nil).  The convention isn't important; only that it is a comparator and not a simple xor function.

For example, use as a sorting predicate:

(sort '(nil t t nil t nil nil nil t)
      (lambda (a b)
        (and (not a) b)))
 = > (nil nil nil nil nil t t t t)

(sort '(nil 1 5 nil 3 nil nil nil 2)
      (lambda (a b)
        (and (not a) b)))
 => (nil nil nil nil nil 1 5 3 2)


texts: Custom command like execute-extended-command

texts:
I want to implement a custom M-x (execute-extended-command).
This time real skeleton-coding (crying)

(defun gbq-extended-command (inst)
  (interactive "sgbq-X ")
  (cond ((equal inst "eob") (end-of-buffer)))
  ;; BODY of function
  )

in this function, I want completion instruction. for example, if call the function, like M-x, when I type eo, Completion from eo to eob.
but I have no idea how.


texts:
I use org-mode clocks to keep track of my work hours, and the timesheet is expected to be grouped by day. The thing is, I sometimes work late at night, and the daily view shows work splitted up like this:

  Daily report: [2017-01-11 Wed]
  | Headline                                   | Time   |      |
  |--------------------------------------------+--------+------|
  | *Total time*                               | *1:06* |      |
  |--------------------------------------------+--------+------|
  | something                                  | 1:06   |      |
  | \emsp Some task                            |        | 1:06 |

  Daily report: [2017-01-12 Thu]
  | Headline                                   | Time   |      |
  |--------------------------------------------+--------+------|
  | *Total time*                               | *3:10* |      |
  |--------------------------------------------+--------+------|
  | something                                  | 3:10   |      |
  | \emsp Some task                            |        | 3:10 |

Is there any way to have the clocking command put all hours in the first day's report? Maybe by providing an offset for when a day starts?


texts: Auto save is disabled but emacs is making files in the format .#file-name

texts:
I set auto save to nil after discovering this, but they keep popping up. Does anyone know what could be causing this?

It's not the typical #filename#, it's making a dotfile .#


texts: Find and display duplicated regions of (org-mode) text across multiple files

texts:
What I'm trying to do

I'm trying to condense a set of research notes consisting of over 250,000 words across 50+ files. I've converted these from previous file formats (mostly mind maps and OPML files) into org-mode. There are lots of duplicated notes where I previously created new versions of files  to allow me to rework ideas.

I have begun consolidating, but I get the feeling there may be a very emacs method of speeding up this process.

What I've done.

I've tried using org-agenda, helm-swoop, helm-ag-edit, iedit, multiple-cursors, multi-occur, diff, ediff, and compare-windows.

What I've learnt

I've found that the most important aspect I require is context. For example:

Most search functions compile a set of matching lines into another buffer. Even if I show the 8 lines around a match, this doesn't often convey enough of the context for me to be able to recognise a duplicate entry.
There are lots of duplicate lines that provide subcategories. While the line is indeed a duplicate, its context is not. For example, Types and Issues below:

* Cars
** Types
*** Sedan
*** Station wagon
** Issues
*** Maintenance
*** Running costs
* Pets
** Types
*** Cat
*** Dog
*** Rabbit
** Issues
*** Fur
*** Toilet training

Manually matching up compare-windows has been the best option so far. It has allowed me to find out just how far a duplicate stretches, often including multiple lines. However, using it alone is quite a manual process:

Find the start of a duplicate between two windows.
Place the cursor at the start of each duplicate in each window.
Run compare-windows to find the end of the duplicate region.
Manually select the region just compared in one of the windows and delete it.

With the myriad of emacs search functions, I'm wondering ... can I do better?

The query

What functions, or combination of functions, could help me to fulfil one or more of the following actions?

Find duplicated sections of text.

Using either a full line, or start of a line, or a moving window, as the minimum amount of text to match, but then expanding the match as far as possible.
potentially only matching the text content and ignoring org-mode heading levels and whitespace differences.
potentially ordered from longest duplicated section of text to some shortest amount of duplicated text (maybe 3-6 words minimum??)
at a later stage, potentially with the option for fuzzy matching of lines.

Show a list of the matches.
Display duplicated sections of text in side by side windows.

potentially highlighting each duplicated section in some way to show not only where the duplicate starts but where it ends.
preferably while leaving the list of matches still open in its own window.

I don't care how CPU intensive the search process is as long as when I come to working though the list of matches, emacs is responsive. I'm using Spacemacs.

Does anyone have suggestions?


texts: Recommended use of non-file-visiting revert-buffer-function

texts:
Summary

I am working on a major mode derived from special-mode, which populates its buffers with formatted lists of items retrieved from a web API. Reverting such a buffer involves refetching and reformatting said list of items. I would appreciate advice on whether to tailor this custom function to revert-buffer-function or to make it standalone.

Initial thoughts

For revert-buffer-function:

Better integration/consistency with rest of Emacs

revert-buffer is already bound to g in parent special-mode-map
running {before,after}-revert-hook in revert-buffer-function makes sense and affords more customisability

For standalone revert command:

Allow custom interactive arguments

For example, how many items to fetch
revert-buffer-function arguments make little to no sense in a non-file-visiting context and cannot be reused for an alternative purpose

Prefix argument to revert-buffer cannot easily be retrieved from revert-buffer-function - this probably begs a new SE question

Docstring becomes clearer, more specific and more readily accessible, i.e. the user does not have to read about revert-buffer, inspect revert-buffer-function or ignore the file-visiting-specific arguments

Practical examples

eww.el provides a standalone eww-reload command with custom interactive arguments, but also comments FIXME: revert-buffer-function instead!
Most non-file-visiting modes I have come across both within and without the Emacs tree are more or less evenly split between rolling out a custom command and using revert-buffer-function with ignored argument(s)

Conclusion

The fact that the prefix argument to revert-buffer-function is file-visiting-specific, together with last-prefix-arg not being usefully bound to the prefix argument to revert-buffer, suggest revert-buffer-function is not really intended for non-file-visiting purposes and so it is unnecessary to seek too deep a level of integration with this mechanism. Is this a sound conlusion? Is there a better use of revert-buffer-function or similar mechanisms than the way described herein? Would extending the flexibility of revert-buffer constitute a useful feature request?


texts: Unmap C-c from org-latex-preview-fragment

texts:
I don't like that C-c C-c is untoggle the org-latex-preview fragment because it's the "magic key" in org and whenever I press it it untoggle my latex-fragment so I have to toggle it again manually.

I would like to unmap this function from C-c C-c and map it to another key like [f9].

I don't understand quite well the part on remapping in the GNU manual so I am asking here. Also I apologize for my lack of vocubalary...


texts:
I am using the relative-line-numbers-mode and a 90 degree turned screen, which makes the text jump when it goes from displaying 100 in the relative number.

Is it possible to set a fixed width for the line numbers, i just need it set to 3 characters.


texts: Given a keyboard command, how do you find the interactive function?

texts:
I have a key sequence for C-u C-c . How would I find the function that's bound to it.  I thought it was describe-key but that doesn't seem to work.

Cheers


texts:
Is it possible for gnus-demon to be asynchronous and silent?

I have this:

(gnus-demon-add-handler 'gnus-demon-scan-news 5 nil)

And every 5 minutes, emacs gets stuck fetching new stuff. Which is annoying.

If gnus-demon itself can't do that (and looking at the code, the best I see is the "idle" mode), is there an alternative?


texts: How to make ordered lists collapsed by default in org mode

texts:
Suppose, we have this org file:

* Header1
** Header1-1
** Header1-2

* Header2

   1. Item 1

      1. Item 1-1
      2. Item 1-2

   2. Item 2

When I open it by default it looks like this:

* Header1...
* Header2...

Unordered items are collapsed. But when I open Header2, all the elements of the ordered list items are visible, so I see this:

* Header2

   1. Item 1

      1. Item 1-1
      2. Item 1-2

   2. Item 2

I can cycle visibility by moving the cursor to Item 1 and clicking <tab>. Is it possible to make the ordered lists collapsed by default?


texts:
Starting from the existing customization associated with key j, is there a way to view and modify the target file? In other words,

by default, captured notes would go to */journal/inbox.org,
optionally, input a different path, say */journal/pc.org.

Could you suggest ways to do that?

~/.emacs:

 '(org-capture-templates
   (quote
    (
     ("j" "Journal" entry
      (file+olp+datetree "~/Documents/write/notes/journal/inbox.org")
      "* %?
Entered on %U
  %i
  %a")
     )
    )
   )

Manual:

Handling links
Capture


texts: Emacs slows to a crawl when Chrome is running

texts:
Really bizarre issue here; I suspect it's X-related. This may be better suited to the Linux/Unix SE, but I figured there might be more domain-specific expertise here.

Often (but not 100% of the time), if I run Emacs and Chromium (or google-chrome, I'm on Ubuntu) at the same time, then UI updates on Emacs take ages to show. As in, I'll try to scroll around the package menu and it will take 45 seconds to render a few dozen lines worth of scrolling. It seems to go both ways: I'm updating 31 packages in the background as I type this and there's a few seconds of lag between every character I type and the on-screen rendering.

This issue occurs with both emacsclients and stand-alone Emacs sessions. I have 6 cores and I see that only one of them is being used at the moment, which I think must be the cause of the issue. I 'm only at 60% memory usage with almost no swap space being used, so it's not a question of the system being over-taxed.

It looks like the lag spikes correlate with CPU-intensive actions in Emacs. It's almost as if chromium and Emacs have decided to run on the same core and compete for cycles, but I can't imagine why.

I'm on the latest Ubuntu release, via Xubuntu, and I use XMonad as my window manager. I've never had any other pair of programs have this kind of issue. Firefox doesn't cause this problem, I only discovered it recently after switching to Chrome. What's going on here?


texts:
I want to add advice to `describe-function'.  However, when I try to do so, I get an error due to wrong number of arguments.  Function:

(defun describe-function-advice (function)
  (interactive)
    (setq-local help-buffer-type "describe-function")
    (setq-local help-buffer-arg function))

(advice-add 'describe-function :after #'describe-function-advice)

Error:

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 0)
  #f(compiled-function (function) "Display the full documentation of
    FUNCTION (a symbol).\nWhen called from lisp, FUNCTION may also be
    a function object." (interactive #f(compiled-function ()
    #<bytecode 0x12b6b$
 apply(#f(compiled-function (function) "Display the full documentation
   of FUNCTION (a symbol).\nWhen called from lisp, FUNCTION may also
   be a function object." (interactive #f(compiled-function ()
   #<bytecode 0$
 describe-function()
 funcall-interactively(describe-function)
 #<subr call-interactively>(describe-function nil nil)
 apply(#<subr call-interactively> describe-function (nil nil))
 call-interactively@ido-cr+-record-current-command(
    #<subr call-interactively> describe-function nil nil)
 apply(call-interactively@ido-cr+-record-current-command
    #<subr call-interactively> (describe-function nil nil))
 call-interactively(describe-function nil nil)
 command-execute(describe-function)

For the given problem, I can probably use `help-fns-describe-function-functions', but I would still like to understand how to use advice-add with interactive functions.


texts:
I want to be able to add a #+NAME to a property drawer that would name a code block thats split between sub org headers. Im at loss on how this is done?

this is a current example of a tmux conf thats split with different org sub headers:

 * tmux conf
 :PROPERTIES:
 :header-args: :noweb yes  :tangle /zeltak@132.72.155.204:~/.tmux.conf
 :END:

***** Mouse
      :PROPERTIES:
      :ID:       ba8ce7aa-2b3b-43be-816d-ea2ab515a999
      :END:
#+BEGIN_SRC conf
#-------------->  mouse
setw -g mouse on
set-option -g status-keys vi
#+END_SRC

***** Theme and look
      :PROPERTIES:
      :ID:       85257f51-1306-4caf-a055-a6df3afac1a5
      :END:
#+BEGIN_SRC conf
#--------------> THEME AND LOOK
#default theme picker
source /home/zeltak/.tmux/neonB
#source /home/zeltak/.tmux/solarized-dark
#+END_SRC

I want to add a name (#+NAME) for all the sub headers that will make '.tmux.conf'. anyone know how thats done?


texts: How to switch between Ivy completion styles?

texts:
There are three Ivy completion styles:

ivy--regex-plus
ivy--regex-ignore-order
ivy--regex-fuzzy

C-o (hydra-ivy/body) m toggles between ivy "ivy--regex-plus" and "ivy--regex-fuzzy".

How to switch to ivy--regex-ignore-order completion style?

For example, if I wanted a list of all functions that contain the string "spell",
from help describe functions I would: enter "spell" and switch to ivy--regex-ignore-order.

I am using Emacs 25.2.1 with Evil Spacemacs and Ivy on Linux.


texts:
I take a lot of different MOOC and each class declare own deadline relative to some time zone.

Are there any Emacs mode that show date/time in buffer for several selected time zones in same time?

I expect that mode should understand usual time zone names like UTC+2, EET. See https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations

Also mode should display time in different formats (ISO and American AM/PM). I miss one deadline on half hour just because I didn't know what is 12:59 AM (I think it should be at noon but actually it on deep night).


texts: Is it possible to use Bash for Windows as the term in Emacs for Windows

texts:
When I run M-x term on the Windows version of Emacs, I am prompted to run C:/Program Files/emacs/libexec/emacs/25.1/x86_64-w64-mingw32/cmdproxy.exe

New versions of Windows 10 have the Linux subsystem and its shell (which is installed at C:\Windows\System32\bash.exe ~).

Is it possible to use this executable as the shell in Emacs?

I tried just pasting that path into the Run Program: path but I get the: Spawning child process error.

Is it  possible to use this shell instead on Windows Emacs?


texts: How to toggle whitespace mode in evil insert state?

texts:
I'd like to disable whitespace-mode while in evil  insert state. The following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

While this example uses evil-mode, similar logic applies to any other hook.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?


texts: Adding padding to the left of text in buffer

texts:
I have been looking around for some fix for this but I cannot google-fu my way out of it. I have tried setting the fringe, but that doesn't seem to work. Right now I have the code

(unless (bound-and-true-p linum-mode)
  (setq left-fringe-width 10))

To give my text some space to the left of the edge of the buffer when linum-mode isn't enabled. This is because with neo-tree active its hard to see the edge of the text sometimes, and the text is pressed right up against the edge of the window. However, this doesn't seem to work. Is there a better method to do this? I am using console Emacs.

Thanks!


texts: What is the preferred structure of Emacs configuration?

texts:
As every tinkerer will know, my Emacs configuration is steadily growing.

To get a some sense of having a structure, I divided it in seperated files, each for every category. But I noticed lately that some people organize their configuration in an different way than I do.

Suppose they have the confiugration foo-configuration.el, they put (provide 'foo-configuration) at the bottom of the file.
In their dot-emacs/init.el they call the configuration with (require 'foo-configuration).

But I do it in the other way. I create bar-configuration.el.

In my dot-emacs/init.el, I call the configuration with (load "C:/Dropbox/Emacs/bar-configuration.el") which suits my needs.

But I'm wondering if I'm missing something important (I'm relatively new to Elisp).
Is there any advantage to use provide/require above the latter?


texts:
I'm using Gnus for the first time with gmail.

I have a lot of emails which I've read but just don't delete, 20k or so.

I want to access them more like the web browser that is only the newest 100 or so.

How can I do this?

My ~/.authinfo:

machine imap.gmail.com login kirkins@gmail.com port imaps
machine smtp.gmail.com login kirkins@gmail.com  port 587


texts: Helm-mode change default keybinding for "helm-find-files-*" * -> "down-one-level" (?)

texts:
I wan't to switch the keybinding in helm-find-files when I go one level up or go in to a folder. Now it looks like:

"C-j" -> go in to the folder
"C-l" -> go one level up

For me, it's intuitive to switch them, so it will be the following:

"C-j" -> go one level up
"C-l" -> go in to the folder

I could replace the "C-j" to the one I wanted with this:

(define-key helm-map (kbd "C-j") 'helm-find-files-up-one-level)

I don't know what's the action's name to "go in to the folder". If I find it out, that could be a solution.


texts:
Is there an org-mode hook that fires before org loads?

I have some font-lock settings that require me to run org-reload for theme to stick. But I thought it might be cleaner if I could wrap these settings in a hook that fires before org loads, to begin with?


texts: Have Time showing up only in hours and not converted to days

texts:
I have a table were I get the time worked for this week. However it shows the time in "days hours minutes". I would prefer only hours. Is that possible?

* work clock tasks week
#+BEGIN: clocktable :maxlevel 3 :narrow 100 :scope file :tstart "<-1w>" :tend "<now>" :step week :link

Weekly report starting on: [2019-01-15 ter]
| Headline                                                       | Time       |       |
|----------------------------------------------------------------+------------+-------|
| *Total time*                                                   | *1d 10:33* |       |

...

#+END:

So I would like Total time to show 34:33 instead of 1d 10:33. Is that possible?


texts: Helm bind "C-j" and "C-k" to list navigation (cursor position)

texts: Is it possible to change binding to navigate throw Helm list via C-j and C-k bindings? I came to Emacs from Vi(m) world and I really want to keep this mapping in my emacs + evil setup.


texts: Make the emacs command history size unlimited so I can keep track of files?

texts: I'd like to make the size of the emacs command history unlimited.  I open and edit too many files in many different folders and I need a way to keep track of them.  The emacs command history looks like a good place to do that. How can I do that?


texts: “call-process” hangs and does not launch the program

texts:
I’m dipping my toes into reading news with Gnus. I’d like to continue using the same editor as before for composing posts, so I put these forms in my gnus.el:

(setq message-tab-body-function 'edit-in-vim)

(defun edit-in-vim ()
  (let ((filename (make-temp-file "gnus_vim_" nil ".usenet" (buffer-string))))
    (call-process "/home/bdesham/.nix-profile/bin/vim" nil nil nil filename)
    (insert-file-contents filename nil nil nil t)))

My intention is to do the following:

Write the current buffer into a new temporary file.
Run Vim to edit this temporary file. Wait for Vim to exit.
Replace the current buffer’s contents with the file’s contents.

Step 1 works fine—when I hit Tab in a message buffer, I see

  Wrote /tmp/gnus_vim_BE6h2K.usenet

at the bottom of the screen. At that point, though, Emacs hangs and won’t do anything until I type C-g. If I run ps during this hang, it doesn’t look like a new Vim process was created.

Am I using call-process wrong? Or is it not intended to be used to call programs that have their own terminal UI? How can I get this kind of external-editor functionality?


texts: Export org-mode tables to LaTeX mathematics matrices?

texts:
Does anyone have a good way to produce LaTeX mathematics matrices  from org-mode tables?

I found this thread but it doesn't seem to have a ready-made solution.

This gets me close.

#+LATEX: \begin{equation}
#+LATEX: \begin{matrix}
| a | b |
| c | d |
#+LATEX: \end{matrix}
#+LATEX: \end{equation}

which exports to:

\begin{equation}
\begin{matrix}
\begin{center}
\begin{tabular}{ll}
a & b\\
c & d\\
\end{tabular}
\end{center}
\end{matrix}
\end{equation}
\end{document}

And I only have to take out the tabular and center directives.


texts: org mode: retrieve current heading and parents programmatically

texts:
In org-mode whenever I have point on heading it shows me in the mini buffer the full hierarchy. For example, if I have the following in a Org file:

* lvl1
** lvl2
*** lvl3
    some text

And I put point on lvl3 it shows /lvl1/lvl2/lvl3 in the mini buffer. Is there a specific function I can call to obtain this information? I sometimes need to retrieve context and with this it would be easier, no need to move point to the heading.


texts:
Recently I discovered emacs as a text editor for my latex documents. So far, I am excited with how powerful the editor is. However, I have a problem with line wrapping.

More precisely, in the option menu I choose line wrapping in this buffer --> word wrap. After that, I choose save options, but when I reopen my tex file, line wrapping is back to the default setting.

So, my question is how can I set word wrap as my default wrapping option for all my documents?

Thanks in advance


texts: How can I prevent Org from exporting [[/][site root]] as site root?


texts: How to copy command output in ansi-term mode?

texts:
In ansi-term mode, is there a way to copy the command output? This is quite easy in eshell, but sometimes eshell behavors not exactly the same with bash. For example:

eshell doesn't know how to auto-complete sudo apt-... command.
eshell requires to input password each time I run a sudo command.

So I have to use ansi-term from time to time.


texts: Newbie: Simple setup for dired in sidebar?

texts:
Simple question from a new Emacs user: I'd like to have my editing window have a sidebar (or a divided window, or a frame--I'm not sure of the terminology or the options here) that has a dired (or something else--any kind of interactive directory listing) in it.

The Emacs manual has complicated instructions for setting up top, bottom, or side frames, and I haven't been able to find a simple blog post or something that says, "This is what to do."

Basically I'd like my Emacs to look more like an IDE and less like an antique terminal window.


texts: How to RPC from External Process to Emacs

texts:
How can I RPC from an external application into Emacs then have a function in Emacs handle the RPC?

For example, I would like to make a D3.js webpage with a dependency graph of a codebase, view and navigate the graph in Google Chrome, and clicking a node should tell Emacs to display a buffer of the given source file.

Minimal amount of code written would be nice, and preferably native Emacs functionality, unless 3rd party package is the only way.


texts: Search/substition completion in Evil mode

texts:
In Evil mode, in the Normal state, with the evil-search-module variable set to Evil interactive search, I would like to use some kind of auto-completion functionality like Ctrl+n or Ctrl+p so that I don't have to type the full string I am searching for. For example, if I wanted to turn the line

foo bar grue

into

foo bar zork

I would like to be able to do something like this:

Type :s/g
Hit Ctrl+n (or some other concise key/combo).
See the command prompt change to :s/grue.
Type /zork<RET>.

The steps I've given above fail at step 2. At that point, instead of using the next match, Evil outputs the error message, "No later matching history item".

I have also tried using the suggestions given as answers here, but these do not work either:

Hitting Ctrl+f while in the middle of entering a substitution command simply causes Emacs to output the message "End of buffer".
Using q:is/g<Ctrl+n> causes Emacs to output the error message "No dynamic expansion for `s/g' found".

What can I do to overcome or work around this?

Update: see Evil bug #166, which refers to this issue.


texts: Navigation in eww, following links, bookmarks

texts:
When the cursor in eww is over a link, how can I follow it? Right now I copy it with 'w', and run eww again, which is kind of cumbersome.

In the same venue, if I access the bookmarks with 'B', how can I follow it, without copying and pasting after running M-x eww?


texts:
I'm new to org mode. Something about levels in org mode confused me but i found no info around (both in tutorials and Google).

I can put text under any heading, and the text is treated as a child node of the heading. But I wonder, is it possible to lay some text in the same level with some other headings?

Example:

* Heading Level 1
    Some Text A
    ** Heading Level 2
        Some Text B
    Some Text C

My purpose is to put 'Some Text A' and 'Some Text C' under 'Heading Level 1' but parallel to 'Heading Level 2'.

The default way of org mode is that 'Some Text C' is treated as a child of 'Heading Level 2' (just after 'Some Text B'), which is not I want. Noted that 'Some Text A' performs well.


texts: Problem with font in markdown-mode table

texts:
I am using variable-pitch for markdown-mode. Tables use fixed-pitch (markdown-table-face). The table aligns for regular text. It breaks alignment for links. The spaces are also underlined.

Considering a link [foo](bar), the first part - [foo] - shows text properties face as (markdown-table-face and markdown-link-face). This part renders as fixed-pitch. The next part - (bar) - shows text properties face as markdown-url-face. This part renders as variable-pitch.

I think if we can prepend markdown-table-face to the text properties list of the (bar) then it would render correctly?  How can I do that?  Or is there any other means to achieve this?


texts: Spacemacs auto-mode-alist appears to be disabled

texts:
I've been having this trouble for a little while.  Whenever I open a new file in spacemacs, it always opens in fundamental mode.  I'm on a clean install of spacemacs on windows 10 if that matters.

To see what the content of auto-mode-alist was, I opened the scratch buffer, started an inferior emacs lisp, typed the variable name, and pressed enter.  I saw a lot of output, the first of which was the association of *.el files with emacs-lisp-mode.  So I tried opening a new .el file, but I still got fundamental mode.  I then set auto-mode-alist to contain just the association of *.el files with emacs-lisp-mode.  I opened another new file, but I got the same result.

So here is a question: is there a way to disable the auto mode choosing of emacs? Is there a setting that could possible interfere with it that I might have accidentally somehow set (but I'm on a clean spacemacs, so I don't know how it would happen)?

Note, non-spacemacs emacs works fine.

I should also note that when I open a file with windows line endings, I see lovely ^M characters at the end of all the lines.  Without spacemacs, emacs picks up on the line endings and acts appropriately by hiding them.


texts:
I'm setting up a remote editing capability through Tramp from my Mac OS X laptop to an Ubuntu box, and have defined the following:

(setq tramp-default-user "myusername"
      tramp-default-host "myhostname")
(setq tramp-default-method "ssh")

;;Open a file on my linux box
(defun remote-find-file (file-name)
  "Like find file, but opens the file on my box"
  (interactive "FRemote Find File: ")
  (let ((tramp-file-name (expand-file-name file-name)))
    (find-file tramp-file-name)))
(global-set-key (kbd "C-x C-u") 'remote-find-file)

The issue I have is that expand-file-name is expanded using the Mac OS X conventions, so that ~ turns into /Users/myusername instead of /home/myusername. I suspect there's a way to fix this using file name completion, but I can't figure it out from the Tramp documentation.


texts: Can I use calc-eval to solve an equation?

texts:
I regularly use calc-eval in the *scratch* buffer to work out some quick calculations. I know that I can use some simple functions inside the calculation string, e.g. log. However I am not certain whether I can use the solver in the same way.

Is it possible to write a calc-eval expression that solves for, say, a particular variable?


texts:
I am trying to create an org-capture template for a grocery list, but there seems to be no easy way to get the result I want, and I'm pretty bad at programming. So I was hoping that maybe someone has a solution.

I would like to have a template that does the following: I have a grocery.org file, that should have roughly the following structure:

* <Todays Date>
- [ ] item 1
- [ ] item 2

The template should check if there already is a headline with the current date. If so, just add an item to the list. If not, create the headline with the current date and start the list.
I tried a couple of things with the standard tools of org-capture, like (file+headline) and (checkitem) and so on, but I really cant get that done.

I really hope someone can offer some help, thanks in advance.


texts: helm-find-files (and others): how to prevent C-j from creating buffer when no match

texts:
When hitting C-j in the minibuffer while executing helm-find-files and no match is possible, helm creates a new buffer with the name of the completion. E.g. I do M-x helm-find-files, type foo there is only the default match:

Now I hi C-j and a new buffer gets created, named foo. How can I disable this behavior?


texts: Helm swoop: Match all lines starting with a whitespace

texts: How can I match all lines starting with a whitespace in helm-swoop? ^ doesn't work.


texts: How to show all functions in a javascript file?

texts:
How to show all functions in a js file? I am using js2, but any solution will do.

Additional info:
I am expecting an occur style buffer. This can persist and be edited if necessary. Or searched. This is preferable in my opinion to a helm style navigation tool for two reasons: 1. Helm is useful for navigating quickly to a known entity, but not for grokking structure. 2. I can continue investigation and keep that buffer alive as alluded to above.

What have I tried? I tried using a straight up occur, but the regex started to get too complex, and I imagine there is a better solution. I also know that js2 or something can parse js properly, and surely that would do something close to what I need, and properly too.


texts: Problem creating an org-mode link to a pdf file from PDFView

texts:
When I try to store a link to a pdf file (opened with PDFView), I get the following error

Unable to percent escape character: \342

The link is stored with the following url:

Stored: file:/tmp/mozilla_chriad0/file.pdf::%PDF-1.6 %\324\343\317\323

When looking for a solution, I found the url-util package. I came up with the following:

(setq x "file:/tmp/mozilla_chriad0/file.pdf::%PDF-1.6 %\324\343\317\323")

(require 'url-util)

(setq y (url-encode-url x))

When I create a link with the content of y, which is [[file:/tmp/mozilla_chriad0/file.pdf::%PDF-1.6%20%%D4%E3%CF%D3]], the link works as intended.

My question: How can I hook into this process and convert the link to the right encoding so that the above error does not occur?


texts: Helm-Projectile find -perm /444 illegal mode string

texts:
I'm using emacs on the mac and helm-projectile is acting up.

It's still working for files in current dired buffer, but the find-files feature is throwing the error:

find: -perm /444: illegal mode string

I recently installed powerline and I'm wondering if it has anything to do with the mode line, but I'm not sure if that's the case.

Has anyone ever had this error before?


texts: Programmatically add files to existing Dired buffer

texts:
I have an existing dired buffer created of arbitrary files (basically as described here). How could I add additional files to this existing buffer?

The files may, or may not, be in the same directory as any files in the existing dired buffer.


texts: What mode does the command `query-replace' activate?

texts:
I'm editing my keybinds mode-by-mode, and I've now come to the query-replace-map.

I want to define my keybinds in a mode-hook to keep my files logically consistent, but I cannot determine which mode the command query-replace activates.

I've tried M-x describe-mode, but activating the minibuffer immediately disables query-replace, thus I cannot look at the list of modes the buffer is currently in.

Or are query-replace/isearch-query-replace even modes?
If not, what sort of functionality is this, and how should I handle the rebinding of keys in these peculiarities (using mode-hooks or any other method that I might not know of)?

Also are there any other caveats when dealing with these pseudo-modes?


texts: OS X emacs: difference between X11 vs NS vs Cocoa?

texts: I believe, there are three ways to build emacs on osx --- x11, ns (nextstep?), and cocoa. Can anyone explain what the build options mean / the difference between these three are?


texts: Specify which emacs to open for a file when running shell inside emacs

texts:
Consider a scenario

I run an emacs instance E01, and use the shell inside emacs to find the file I want to open;
I found the file file using this shell. Now I'm ready to open it through the shell command emacs file.
This file is now open in a new emacs instance E02, different from the one where the shell runs.

And My question is, for the second step of my scenario, when I try opening the file using emacs file, how to use the same emacs instance (i.e. E01 in this case) for it?


texts: Undesired auto expansion with company-mode and python-mode

texts:
I am using company-mode and python-mode (note the same issue does not happen with python.el) and something about the combination is causing emacs to automatically expand at point. For example, if I type "R" it will expand immediately to "REDISTRIBUTING", it seems to be looking in all of my buffers for dabbrevs.

Minimal working init is below. How can I disable this behaviour or at least figure out where the bug lies so that I can report it. I am using emacs 24.4 on OSX (Yamamoto Mitsuharu's port). I would also be interested in knowing whether others can replicate this.

(add-hook 'after-init-hook 'global-company-mode)

(autoload 'python-mode "python-mode" "Python Mode." t)
 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
 (add-to-list 'interpreter-mode-alist '("python" . python-mode))


texts: Setting fonts in org-beamer with Metropolis theme

texts:
Environment: OSX 10.13.4, spacemacs 0.200.7

Here's a pared-down org-beamer file

#+TITLE: A Presentation
#+SUBTITLE: A really good one, in fact
#+AUTHOR: WallyMetropolis
#+DATE: 05-02-2018
#+OPTIONS: H:2 toc:1 num:t
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [presentation, usepdftitle=false, bigger]
# Have to set Metropolis specific package options here
#+LATEX_HEADER:\mode<beamer>{\usetheme[numbering=fraction, progressbar=frametitle, titleformat=smallcaps]{metropolis}}
#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
#+BEAMER_HEADER:\setmainfont{Fira Sans}
* Testing
** How does it look?

I export this to a pdf with M-x org-beamer-export-to-pdf

I'd like to use the Fira font recommended by the Metropolis theme, but I'm unable to correctly install or set the font.

I have tried variations on setting the font, including

#+BEAMER_HEADER:\setmainfont{Fira}

or

#+BEAMER_HEADER:\setsansfont{Fira Sans}

in the org file.

and the Org PDF LaTeX Output shows

! Undefined control sequence.
l.51 \setsansfont
   {Fira Sans}

To install the font itself, I tried:

brew tap caskroom/fonts
brew cask install font-fira-code

But I'm unconvinced that this made the font available for an org-beamer pdf export.

I have also tried things like

sudo tlmgr install fira-sans

which resulted in

Unknown directive ...containerchecksum 400c4de374d03934965b5488f37c1b052ade3eda3zzzzzzzz57c9846390b2b78315c6aed2b533a2271bbacabd77c44536b63973bd42e2686f4c6d25d1f4c5b4709e... , please fix it! at /usr/local/texlive/2014/tlpkg/TeXLive/TLPOBJ.pm line 210, <$retfh> line 6001.


texts: Why is function defined by defun not bound

texts:
intro

Sometimes I want to generate a function programmatically as opposed to defining
one with defun. You may wondering why I'd want to do this. Well, it's
complicated but just bear with me for a moment.

(defun void-defun (fn)
  (let ((name (gensym "void-defun-")))
    (eval
     `(progn
        (message "Created function: %S" name)
        (defun ,name ()
          (funcall #',fn))))
    name))

problem

When I test whether the function is bound with the following code, all is well.

(let ((fn (void-defun (lambda () 2))))
  (and (fboundp fn) (= 2 (funcall fn)) fn))
;; => void-defun-69

after the test

However, after evaluating this test code and calling the function (whose name I
know from the *messages* buffer) I get a void-function error. I expected the
function to be bound as indicated by my test. It is as if the function was bound
temporarily for the execution of my test form then unbound again.

;; This 69 is just as an example of a name I could get.
(funcall #'void-defun-69)
;; => eval: Symbol’s function definition is void: void-defun-69

question

Why does this happen? And how can I avoid this?


texts:
Running emacs 25.2.2.

To add a property, when I C-c C-x p while on a headline in an org file, it creates an error (prior to C-c C-x p, I had done M-x toggle-debug-on-error to produce a detailed stack trace):

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  org-buffer-property-keys(nil t t)
  org-read-property-name()
  org-set-property(nil nil)
  funcall-interactively(org-set-property nil nil)
  call-interactively(org-set-property nil nil)
  command-execute(org-set-property)

After I M-x load-library RET org.el RET it produces the following stack trace:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  goto-char(nil)
  (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x (org-match-string-no-properties 2))) (if (member x rtn) rtn (setq rtn (cons x rtn))))) (outline-next-heading))
  (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x (org-match-string-no-properties 2))) (if (member x rtn) rtn (setq rtn (cons x rtn))))) (outline-next-heading)))
  (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x (org-match-string-no-properties 2))) (if (member x rtn) rtn (setq rtn (cons x rtn))))) (outline-next-heading))))
  (let (rtn range cfmt s p) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward org-property-start-re nil t) (setq range (org-get-property-block)) (goto-char (car range)) (while (re-search-forward org-property-re (cdr range) t) (let* ((x ...)) (if (member x rtn) rtn (setq rtn ...)))) (outline-next-heading)))) (if include-specials (progn (setq rtn (append org-special-properties rtn)))) (if include-defaults (progn (mapc (function (lambda (x) (if (member x rtn) rtn (setq rtn ...)))) org-default-properties) (if (member org-effort-property rtn) rtn (setq rtn (cons org-effort-property rtn))))) (if include-columns (progn (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward "^\\(#\\+COLUMNS:\\|[     ]*:COLUMNS:\\)[     ]*\\(.*\\)" nil t) (setq cfmt (match-string 2) s 0) (while (string-match "%[0-9]*\\([-[:alnum:]_]+\\)" cfmt s) (setq s ... p ...) (if ... nil ...))))))) (sort rtn (function (lambda (a b) (string< (upcase a) (upcase b))))))
  org-buffer-property-keys(nil t t)
  (let* ((completion-ignore-case t) (keys (org-buffer-property-keys nil t t)) (default-prop (or (save-excursion (let ((save-match-data-internal ...)) (unwind-protect (progn ... ...) (set-match-data save-match-data-internal ...)))) org-last-set-property)) (property (org-icompleting-read (concat "Property" (if default-prop (concat " [" default-prop "]") "") ": ") (mapcar (quote list) keys) nil nil nil nil default-prop))) (if (member property keys) property (or (cdr (assoc (downcase property) (mapcar (function (lambda ... ...)) keys))) property)))
  org-read-property-name()
  (or property (org-read-property-name))
  (let* ((property (or property (org-read-property-name))) (value (or value (org-read-property-value property))) (fn (cdr (assoc property org-properties-postprocess-alist)))) (setq org-last-set-property property) (setq org-last-set-property-value (concat property ": " value)) (if fn (progn (setq value (funcall fn value)))) (if (equal (org-entry-get nil property) value) nil (org-entry-put nil property value)))
  org-set-property(nil nil)
  funcall-interactively(org-set-property nil nil)
  call-interactively(org-set-property nil nil)
  command-execute(org-set-property)

What is happening here? How do I set things right?


texts: Get backtrace from error programmatically

texts:
If an error is signalled in Emacs Lisp code, and debug-on-error is t, I get a backtrace buffer that makes it easy to figure out where the error occurred.  However, for errors that occur while processing a response from the network asynchronously, it would be annoying to have the backtrace buffer pop up, so I'd rather catch the error with condition-case and log it.

So when I'm handling an error in condition-case, is there a way to get access to the backtrace at the point of the error?  Calling the backtrace function gets the backtrace of the code inside the handler, which is not what I'm looking for.

(condition-case e
    (do-something-that-might-fail)
  (error
    (message "%s"
             ;; This gets the wrong backtrace!
             (with-temp-buffer
               (let ((standard-output (current-buffer)))
                 (backtrace)
                 (buffer-string))))))


texts: The title pretty much says it all.  I'm looking for something similar to M-f and M-b to move right or left column-wise in an org-mode table.


texts: Aquamacs banner for Latex got ugly — how to get the default back?

texts:
I was setting up Aquamacs as my LaTeX editor on a new laptop (been using it for 4 years on prior machine).

My one problem is that the beautiful header I was expecting:

Was replaced by this ugly mess:

Any thoughts on how to fix this?

I've tried:

uninstalling and reinstalling Aquamacs
direct copy-paste of the ~/.emacs file from my old install of Aquamacs


texts: Invalid modifier in string for command unset "\C-;"

texts:
The command (global-unset-key "\C-;") fails with the message: Invalid modifier in string.

Perhaps because of the special character ;. What is the proper way to unset this key?

Any other normal character works, e.g.: (global-unset-key "\C-c").


texts: How can I delete mu4e drafts on successfully sending the mail?

texts:
As I'm composing mail, mu4e automatically saves drafts to the mu4e-drafts-folder.  When I send the mail, these drafts persist.  I expected mu4e to delete from the folder.

I'm unable to find any documentation in the mu4e manual, and I'm afraid I'm still too new to this codebase to see how to hack together what I want.

Is there a user option to enable deletion on send?  Or an obvious function I can drop into, say, message-sent-hook?


texts: I'm using the "It's all Text" addon for Firefox so I can edit textarea's in Emacs. As I spend some time on a phpBB forum, I was wondering if there is an Emacs mode for phpBB with it's syntax of using [tag] and [/tag]. I'm mainly interested in syntax highlighting, so if no phpBB mode exists, is there something that comes close?


texts: How do I ignore comments with scan-sexps?

texts:
I have some lisp code that contains a comment:

(while list
  ;; take the head of LIST
  (setq len 1))

I want to extract the positions of the sexps. I'm using scan-sexps. If I call M-: (scan-sexps 12 1) with the above code in a buffer, it returns 54, as expected.

However, if I try to do this programmatically:

(setq src "(while list
  ;; take the head of LIST
  (setq len 1))")

(with-temp-buffer
  (insert src)
  (scan-sexps 12 1))

I get 22! This seems to be parsing the words in my comment. Why don't I get 54, and how do I fix this?

Reading the docstring for scan-sexps, it mentions parse-sexp-ignore-comments. However, this doesn't seem to affect the outcome:

(with-temp-buffer
  (insert src)
  (setq parse-sexp-ignore-comments t)
  (scan-sexps 12 1)) ; still 22

How can I make scan-sexps return the end position of the next sexp, ignoring comments?


texts:
I'm currently trying to implement a virtual keyboard. For this to work I need to remap input events in all contexts.

I'm aware of the variables function-key-map and it's siblings, as well as input methods. However, they all seem to be applied to a new key sequences, but not in the middle of a key sequence.

What I need is a way to convert some mouse events into key events. And this should work both at the beginning of a key sequence as well as in the middle of one.

Concretely, if the user clicks on my virtual key for 2, I want the digit 2 to be insert. However, if the user has typed C-x (either on a real keyboard or in my virtual keyboard) and click 2 on the virtual keyboard, I want the window to split (like C-x 2 normally do).

All suggestions on how to precede are welcome!


texts: My function seems to not know a variable has changed and gives the wrong output

texts:
I want to change the shebang string every time I create a new Python file, some projects use Python 2 and other use Python 3, so the shebang should change according to the value of a variable in the .dir-locals.el file of the project.

To generate the header text I use header2.el. There is the code I have so far:

(defvar-local shackra:var-python-ver 2
    "Indica que versión de Python estamos usando, Python2 o Python3")
(put 'shackra:var-python-ver 'safe-local-variable-values #'integerp)

;; configuración basica para python-mode y elpy-mode
(setf python-indent-guess-indent-offset nil
    python-indent 4
    python-indent-offset 4
    elpy-modules '(elpy-module-company
        elpy-module-eldoc
        elpy-module-pyvenv
        elpy-module-yasnippet)
    elpy-rpc-backend "jedi")

;; habilita elpy
(elpy-enable)

(defun shackra:python-switch-python-version ()
    "Cambia entre (i)Python2 o (i)Python3 dependiendo de ciertas variables"
    (if (eq shackra:var-python-ver 2)
        (setf elpy-rpc-python-command "python2"
            elpy-interactive-python-command "ipython2"))
        (setf elpy-rpc-python-command "python3"
        elpy-interactive-python-command "ipython"))

(defun shackra:header-python-shebang-coding ()
    "Inserta los famosos shebang (#!) y “coding”"
    (if (eq shackra:var-python-ver 2)
        (insert "#!/usr/bin/python2\n")
    (insert "#!/usr/bin/python3\n"))
    (insert header-prefix-string "-*- coding: utf-8 -*-\n\n"))

(add-hook 'python-mode-hook (lambda ()
    (electric-indent-local-mode -1)
    (shackra:python-switch-python-version)
    (setf make-header-hook '(shackra:header-python-shebang-coding))
    (auto-make-header)
    (py-autopep8-enable-on-save)))

If the content of a .dirs-locals.el for a directory is:

((python-mode
    (shackra:var-python-ver . 3)))

My configuration changes correctly in (shackra:python-switch-python-version), however, (shackra:header-python-shebang-coding) inserts the string #!/usr/bin/python2 when creating a new Python file inside that directory.

Why does this happens and how can I fix this?


texts:
By default, text between slashes is italicized:

Is there a way to have org mode hide the slashes while keeping the text italicized?

UPDATE

NickD's answer below works great! Here's what it looks like:


texts: with-query-replace-color: macro or function?

texts:
I'm trying to create my first macro. I often change the background color of the query-replace matched string in my script. I usually do:

(let* ((face 'query-replace)
       (bg (face-background face)))
  (unwind-protect
      (progn
    (set-face-background face "gold")
    (perform-replace "^%+\n" ""  t t nil 1 nil (point-min) (point-max)))
    (set-face-background face bg)))

Now I'd like to have a macro to do that. Something like:

(with-query-replace-color "gold"
  (perform-replace "^%+\n" ""  t t nil 1 nil (point-min) (point-max)))

I tried with:

(defmacro with-query-replace-color (COLOR &rest body)
  "Change bg color in `perform-replace'..."
  (declare (indent 1))
  (let* ((face 'query-replace)
     (bg (face-background face)))
    `(unwind-protect
     (progn
       (set-face-background ,face ,COLOR)
       ,@body)
       (set-face-background ,face ,bg))))

I get:

Symbol’s value as variable is void: query-replace.

What am I doing wrong?
Should I use a function instead?


texts: I am Using Emacs GUI on Windows 10 and am having problems entering commands. I am attempting to use C-h t and I am getting the error message C-c h is undefined. What am I doing wrong?


texts: Which function should I advise to do something when a user-error is unhandled?

texts:
I need to advise emacs to do something when any error dings to the user. I can't find any documentation on which function I actually need to advise.

Which function do I need to advise to do something when a user-error is unhandled?


texts: I'm new to using ERT for testing my Elisp code, and I have a question that doesn't seem to be covered in the manual: according to best practices, where does one typically put the ERT tests? Do they go at the end of the elisp file that is to be tested, or should I put them in a separate file? I'm sure they'll work either way, but is one or the other preferred?


texts:
I'm trying to install exwm on NixOS 20.09.
I use emacs 27.1.
My init file:
(require 'package)
(setq package-archives '(("gnu"   . "https://elpa.gnu.org/packages/")
                         ("melpa" . "https://melpa.org/packages/")))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))

Emacs complaints when evaluating
package-refresh-contents
with the following backtrace:
Debugger entered--Lisp error: (error "elpa.gnu.org/443 Name or service not known")
  signal(error ("elpa.gnu.org/443 Name or service not known"))
  package--with-response-buffer-1("https://elpa.gnu.org/packages/" #f(compiled-function () #<bytecode 0x976509>) :file "archive-contents" :async nil :error-function #f(compiled-function () #<bytecode 0x97651d>) :noerror nil)
  package--download-one-archive(("gnu" . "https://elpa.gnu.org/packages/") "archive-contents" nil)
  package--download-and-read-archives(nil)
  package-refresh-contents()
  (if (package-installed-p 'use-package) nil (package-refresh-contents) (package-install 'use-package))
  eval-buffer(#<buffer  *load*> nil "/home/user/.emacs.d/init.el" nil t)  ; Reading at buffer position 813
  load-with-code-conversion("/home/user/.emacs.d/init.el" "/home/user/.emacs.d/init.el" t t)
  load("/home/user/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x7c3935>) #f(compiled-function () #<bytecode 0x7c77c9>) t)
  command-line()
  normal-top-level()

I changed gnu's url to "http://elpa.gnu.org/packages/" and got a similar error
"elpa.gnu.org/80 Name or service not known"

I tried also the commands
curl http://elpa.gnu.org
curl https://elpa.gnu.org

and they seem to work.
How can I fix this, so I can access ELPA as I expect?


texts: Is there a library which can show a popup menu like company's menu?

texts: So I give it a list of items and it shows the menu at point, handles up/down keys automatically, so it works like the company menu. I looked into company's code, but apparently it implements the menu itself. Is there a separate package for such a menu UI only?


texts: How can I append a note to the current currently clocked in task

texts:
I would like to quickly append a note to the currently clocked in task - something like a capture. I don't believe there is anything out of the box to do this, but it seems it must be possible.

Any ideas how?